feat: add Redis Sentinel support to cache and session Redis handlers - #10436
Draft
ddevsr wants to merge 4 commits into
Draft
feat: add Redis Sentinel support to cache and session Redis handlers#10436ddevsr wants to merge 4 commits into
ddevsr wants to merge 4 commits into
Conversation
Add configurable Redis Sentinel support to the Cache RedisHandler and PredisHandler, and to the Session RedisHandler, so the handlers discover the current master from a list of Sentinel nodes instead of a single fixed host. - Add RedisSentinel::discoverMaster() utility shared by both phpredis handlers. It prefers the RedisSentinel class (phpredis >= 5.3) and falls back to the SENTINEL get-master-addr-by-name command for older versions. - Cache RedisHandler: when a sentinel block is configured, discover the master address before connecting; wrap discovery failures in CriticalError. - Cache PredisHandler: hand the Sentinel nodes plus a replication=sentinel and service option to Predis, which discovers and follows the master natively. - Session RedisHandler: new Config\Session::$sentinel property. When populated it takes precedence over $savePath; open() discovers the master and logs + returns false when no Sentinel can answer. - Document the new configuration in the caching and sessions user guide, with sample snippets. - Add unit tests for the discovery utility and sentinel-shaped savePath, plus live tests that assume a local Sentinel on 127.0.0.1:26379 (mymaster), gated on the redis extension like the other live Redis tests. Co-Authored-By: Claude <noreply@anthropic.com>
ddevsr
force-pushed
the
cache-session-sentinel
branch
from
August 2, 2026 16:42
8eca63c to
8eea327
Compare
The previous implementation broke against newer clients: - phpredis >= 6.0 changed the RedisSentinel constructor to a single-array signature, so the positional call threw ArgumentCountError. Drop the RedisSentinel class branch entirely and always use the SENTINEL get-master-addr-by-name command via rawCommand, which works on every phpredis version. - Predis' native sentinel replication routes read commands to replicas when any are known, so a cache write/read round-trip against a sentinel setup with a replica returned null. Replace it with the same discovery model as the phpredis handler: query the sentinel nodes for the master address, then connect a plain single-node client to that master. Co-Authored-By: Claude <noreply@anthropic.com>
CI only provides a plain Redis server on 127.0.0.1:6379, not a Redis Sentinel. The live Sentinel tests therefore failed in CI: master discovery threw, CacheFactory::getHandler fell back to the DummyHandler, whose save() always returns true but stores nothing, so get() returned null. Probe for a Sentinel on 127.0.0.1:26379 and mark the test skipped when none is reachable. Locally (or in CI with a Sentinel service added) the tests run as before. Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add configurable Redis Sentinel support to the Cache RedisHandler and PredisHandler, and to the Session RedisHandler, so the handlers discover the current master from a list of Sentinel nodes instead of a single fixed host.
Checklist: