Support Redis Cluster#6490
Conversation
Merging this PR will not alter performance
Comparing Footnotes
|
Greptile SummaryThis PR adds opt-in Redis Cluster support via
Confidence Score: 4/5Safe to merge; defaulting redis_cluster to False means zero impact on existing deployments, and the new code path is only exercised when explicitly opted in. The change is well-structured: key formatting is centralised, pub/sub channel parsing correctly handles both cluster and non-cluster key shapes, and the oplock contention path produces the correct logical ident after the refactor. The only gaps are cosmetic — the SHA256 hash tag is 64 chars when a shorter value would serve equally well, and logical_redis_key uses a heuristic startswith guard that could misfire on edge-case key shapes in future callers. reflex/utils/redis_keys.py — both the hash-tag length and the strip-heuristic are worth a second look before this code is reused in other contexts. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Client Request] --> B[StateManagerRedis / RedisTokenManager]
B --> C{redis_cluster?}
C -- false --> D[logical_key]
C -- true --> E[format_redis_key]
E --> F[Redis Cluster]
D --> G[Redis Single-Node]
H[Incoming pubsub message] --> I[split channel at first colon]
I --> J[logical_redis_key strips hash tag]
J --> K[Look up in internal dicts by logical ident]
Reviews (1): Last reviewed commit: "Support Redis Cluster" | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Adds opt-in Redis Cluster support via
rx.Config(redis_cluster=True), defaulting toFalseto preserve existing behavior. When enabled, Redis-backed state, locks, token ownership records, token scan/subscription patterns, and lost-and-found channels use stable hash-tagged Redis keys so related operations land in the same cluster slot.The implementation keeps logical Reflex tokens, local cache/lock bookkeeping, and serialized payloads unchanged. Cluster key formatting/parsing is centralized in a small Redis key helper so Redis Cluster support stays transparent to the rest of the backend.
Also added a minor bug fix to the
reflex_clitests, where the tests fail on installed reflex version. When running the local editable version in-repo, it would fail. The version gets patched in themock_check_versionto bypass when testing.All Submissions:
Type of change
Please delete options that are not relevant.
New Feature Submission:
Changes To Core Features: