Skip to content

DOC-7168 Add a connect page for redis-rb (Ruby) - #4230

Merged
andy-stark-redis merged 1 commit into
mainfrom
DOC-7168
Oct 12, 2026
Merged

andy-stark-redis merged 1 commit into
mainfrom
DOC-7168

Conversation

@andy-stark-redis

@andy-stark-redis andy-stark-redis commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Adds a connect page for redis-rb, the only Ruby client without one, and links it from ruby/_index.md. Part of DOC-7168 (epic DOC-7164). The Rust page is in a separate PR.

What's on the page

  • Basic connection: an ACL user, a URL (credentials must be URL-encoded), and a Unix socket
  • Redis Cluster, using the separate redis-clustering gem, including reads from replicas
  • Redis Sentinel: separate credentials for the Sentinels and the data nodes, and connecting to a replica
  • TLS, including mutual TLS (client certificates)
  • Connection pools with the connection_pool gem
  • Timeouts and reconnection
  • Protocol: RESP3 is the default as of 6.0

Client-side caching, smart client handoffs and Entra ID authentication aren't supported by redis-rb, so the page leaves them out.

How the examples were tested

All 21 code blocks ran against local servers:

  • a standalone server with an ACL user and a Unix socket
  • TLS servers with the client certificate optional, and with it required
  • a cluster of 3 primaries and 3 replicas
  • Sentinel

The test copies differed from the page only in ports, hosts, passwords, certificate paths and key names.

Component Version
redis 6.0.0
redis-client 0.30.1
redis-clustering 6.0.0
redis-cluster-client 0.16.7
connection_pool 3.0.2
Ruby 4.0.6
Redis 7.2.7

redis-client 0.30.1 and redis-cluster-client 0.16.7 are the exact versions that redis 6.0.0 and redis-clustering 6.0.0 pin.

The gem install lines weren't run, because RubyGems wasn't reachable from the test environment.

Please review these two caveats

Both are based on what we measured, not on the client's own documentation:

  1. Lost writes after a Sentinel failover. We forced two failovers. After each one, redis-rb kept writing to the old primary until Sentinel turned it into a replica. The old primary then discarded those writes, even though the client had received a success reply for each one: 22 and 20 writes were lost. This matches the caveats added to the other clients' pages in DOC-7167 Add Redis Sentinel connection examples to client connect pages #4229.
  2. Writes can run twice. redis-rb retries once by default. We dropped a reply after the server had already run an INCR, and the default retry ran the command a second time. The page suggests reconnect_attempts: 0 or without_reconnect for commands that aren't safe to repeat.

🤖 Generated with Claude Code


Note

Low Risk
Documentation-only changes with no application or infrastructure code.

Overview
Adds a dedicated Connect to the server page for redis-rb, bringing Ruby in line with the other client guides.

The new connect.md documents how to connect with ACL users, redis:// / unix:// URLs (including URL-encoded credentials), Redis Cluster via redis-clustering, Sentinel (separate sentinel vs data credentials, replica reads, and failover write-loss behavior), TLS / mutual TLS, connection_pool, timeouts and reconnect retries (including non-idempotent command caveats), and default RESP3 in redis-rb 6.0.

The Ruby landing page (_index.md) now points readers to that page for cluster, Sentinel, and TLS setup.

Reviewed by Cursor Bugbot for commit 678cc01. Bugbot is set up for automated code reviews on this repo. Configure here.

New ruby/connect.md covering basic connection (ACL user, URL with
URL-encoded credentials, Unix socket), cluster via redis-clustering,
Sentinel, TLS and mutual TLS, connection pools, timeouts and
reconnection, and the RESP3 default. Linked from ruby/_index.md.
Unsupported features (client-side caching, smart client handoffs,
Entra ID) are left out rather than marked unsupported.

All 21 code blocks ran against local servers (standalone with an ACL
user and Unix socket, TLS with optional and required client certs, a
3+3 cluster, and Sentinel), with test copies differing only in ports,
hosts, passwords, cert paths and key names. Versions: redis 6.0.0,
redis-client 0.30.1 (the exact version redis 6.0.0 pins), connection_pool
3.0.2, redis-clustering 6.0.0 + redis-cluster-client 0.16.7 loaded from
GitHub tags because RubyGems was blocked; Ruby 4.0.6, Redis 7.2.7.

Two caveats rest on measurement. The failover note: a forced SENTINEL
FAILOVER lost 22 and 20 acknowledged writes, because redis-rb only
notices the switch when the demoted primary returns READONLY. The
retry note: with the default reconnect_attempts of 1, a reply dropped
by a proxy made INCR run twice, and even with no retry the server had
applied it before the client raised.

Learned: redis-rb defaults to one retry (redis-client to zero), so writes can run twice out of the box
Constraint: every code block here is run-verified; re-run any edit against a real server
Rejected: copying the redis-rb url docstring | it says url overrides options, but explicit options win (config.rb:233-244, tested)
Directive: keep role: :replica, not :slave, in examples; both work but the docs say replica
Gaps: gem install lines not run (RubyGems blocked); hiredis driver cert-path rule is source-only; RESP2 fallback not run
Recheck: Sentinel failover caveat if redis-rb starts subscribing to +switch-master
Ticket: DOC-7168
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

DOC-7168

@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Redis Memory

Found 5 related items from repository history (5 new this commit):

Memory updated at 678cc01

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@andy-stark-redis
andy-stark-redis requested a review from a team October 9, 2026 09:47
@andy-stark-redis andy-stark-redis self-assigned this Oct 9, 2026
@andy-stark-redis andy-stark-redis added the clients Client library docs label Oct 9, 2026
@andy-stark-redis
andy-stark-redis merged commit d58c3d3 into main Oct 12, 2026
100 checks passed
@andy-stark-redis
andy-stark-redis deleted the DOC-7168 branch October 12, 2026 11:46
andy-stark-redis added a commit that referenced this pull request Oct 12, 2026
Adds a "Connect to Redis Sentinel" section after the cluster section on
the nine connect.md pages (H3 on Jedis to match its neighbors). hiredis
gets a short "not supported" section: v1.4.1 has no Sentinel code.
Ruby and Rust had no connect pages; their Sentinel sections shipped
with the new pages in DOC-7168 (#4230, #4231).

Every snippet ran against a local topology (primary, replica, three
Sentinels, mymaster, quorum 2) in two variants: no auth, and separate
data-node and Sentinel passwords. Test copies differed from the page snippets
only in ports, passwords, and key names. Versions run: redis-py
8.1.0 (GitHub tag source), go-redis v9.23.0, node-redis 6.3.0, ioredis
6.0.0, Jedis 8.0.2, Lettuce 7.8.0, StackExchange.Redis 3.0.0 (NuGet was
blocked; latest is 3.3.1), Predis 3.6.1.

The failover caveats are measured, not inferred. Under a forced
SENTINEL FAILOVER, redis-py, ioredis (default options), a Lettuce
RedisClient connection, Predis, and SE.Redis 3.0.0 kept writing to the
demoted primary for about 10 s, until Sentinel reconfigured it, and the
old primary discarded those acknowledged writes on resync (22 of about
60 in the measured runs). go-redis, node-redis, and Jedis subscribe to
+switch-master and moved within 1-2 s; ioredis with failoverDetector
cut loss to the inherent sub-second window. The .NET page deliberately
has no caveat: 3.3.1 adds an IsStalePrimaryView path that may close the
window, and 3.3.1 couldn't be run here (needs the .NET 10 SDK).

Surprises worth knowing before editing these sections: Jedis
RedisSentinelClient has no replica reads at all; Predis replica routing
is sticky until the first write and the parameters username leaks to
the Sentinels (hence username in each Sentinel URI); go-redis
ReplicaOnly sends writes to the replica too; redis-py sentinel_kwargs
stops socket_* inheritance.

Learned: five of the eight clients on these pages silently lose ~10 s of writes after a graceful Sentinel failover
Constraint: every snippet here is run-verified (some trimmed to fragments of the tested program); re-run any edit against a real Sentinel topology
Rejected: SE.Redis SentinelUser/SentinelPassword options | 3.1.13+, source-read only, never run; page uses SentinelConnect + GetSentinelMasterConnection, which ran on 3.0.0
Rejected: Jedis .serverDefaultProtocol() to silence the 8.x RESP3 WARN | method doesn't exist in 7.x
Directive: add the SE.Redis failover caveat only after testing 3.3.1 or later under a forced failover
Directive: link the go-redis and Lettuce Sentinel URL forms to connection-urls.md once DOC-7165 (#4228) merges
Gaps: no TLS to Sentinels tested on any client; no crash failover, only graceful SENTINEL FAILOVER; SE.Redis 3.3.1 never run
Recheck: SE.Redis credentials example when the .NET 10 SDK is available to run 3.3.1
Ticket: DOC-7167
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clients Client library docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants