Repository navigation
feat: decide client-side cache eligibility from command metadata - #4272
Conversation
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aed1e96085
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
β Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit aed1e96. Configure here.
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f74141cbed
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
β¦adataRecordsCache + some related methods renames
b821b72 to
a316666
Compare
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5310f9f474
βΉοΈ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Change summary
Client-side-cache eligibility came from the hardcoded
CacheConfig.DEFAULT_ALLOW_LISTwhilecluster routing came from
STATIC_POLICIES- two hand-maintained views of the sameCOMMANDreply. They had drifted: the allow list admits
XPENDING,TS.INFOandXREAD, all three ofwhich the server reports as not cacheable. The new
redis/commands/metadata.pymakes commandmetadata the single source for both.
CommandMetadatacarries the routing policies plus thecacheability inputs (
readonly,blocking, key argument,nondeterministic_output,script_runner,dont_cache, metadata completeness);_is_client_side_cacheableis the onlyimplementation of the rules and every field fails closed, so unknown commands are never cached.
MetadataResolverserves records by name, chains throughwith_fallback, and answers routing(
resolve_policies) and caching (is_cacheable) off the same record, memoized per name._STATIC_COMMAND_METADATAis the shipped table, validated against a live Redis 8.10 stack reply(and slightly updated to reflect some library restrictions in the current code).
redis/_parsers/commands.pygainsget_command_metadata()and builds both views from onetraversal, so they cannot disagree; the policy resolvers become the routing projection of a
metadata resolver.
metadata_resolver=is plumbed throughRedis,ConnectionPool,RedisCluster,NodesManagerandClusterPipeline, built once per client, shared with everynode client, and injected into
CacheConfig- into a copy forcache_config=, in place forcache=/cache_factory=.The resolver classes are mirrored in async, but the async clients take no
metadata_resolveryet, since the async stack has no client-side cache available. The metadata logic is used the same way for policy resolvers in async as in sync implementation.Compatibility, against 7.1.0:
+FT.SUGGET,+FT.SUGLENand-XPENDING,-TS.INFO,-XREAD.CacheProxyConnection.send_commandno longer raisesValueError("Cannot create cache key.")when an eligible command carries no
keys; it sends normally and caches nothing.STATIC_POLICIES,DEFAULT_ALLOW_LISTandget_command_policies()are deprecated and unread.RequestPolicy,ResponsePolicy,CommandPolicies,PolicyRecordsmoved toredis.commands.metadata, re-exported fromredis._parsers.commands.policy_resolverdefaults toNoneand is built per client; an explicit one still wins overmetadata_resolverfor routing.RedisCluster._get_command_keysraisesRedisClusterExceptioninstead ofAttributeErrorwhen there is no default node.
Test coverage
New
tests/test_command_metadata.pyand its async mirror cover each eligibility rule as anindependent veto, the unknown/incomplete-metadata refusals, withheld routing policies for the
movablekeysreads, case-insensitive lookup, memoization and its cap, fallback chains, and thedeprecation warnings; the resolver tests from
tests/test_command_policies.pymoved here andwere extended. Live-server tests assert the shipped table still matches a real
COMMANDreplyand that each recorded divergence is still needed.
tests/test_cache.pyandtests/test_connection.pycover the eligibility path and the resolver-injection matrix,tests/test_cluster.pyand its async mirror cover per-client resolvers, pipeline routing,policy_resolverprecedence and the new missing-default-node error. Docs updated indocs/resp3_features.rst.Note
High Risk
Touches cluster command routing and client-side cache eligibility, including which commands are cached and how movablekeys reads are dispatched. Compatibility shims exist, but wrong metadata would misroute or cache incorrectly.
Overview
Makes command metadata the single source of truth for both client-side cache eligibility and cluster routing, replacing the drifted
CacheConfig.DEFAULT_ALLOW_LISTand unreadSTATIC_POLICIEStable.Adds
redis.commands.metadatawith frozenCommandMetadatarecords, fail-closed_is_client_side_cacheablerules, and chainableMetadataResolvers (static/dynamic, sync/async). Policy resolvers become a routing projection of that metadata;movablekeysreads withhold policies so the client still resolves keys itself.metadata_resolver=is plumbed through syncRedis,ConnectionPool,RedisCluster,NodesManager, and pipelines (async clients skip the arg until CSC exists). Cache eligibility now asks the resolver; missingkeys=on a cacheable command skips caching instead of raising. Cacheable set shifts by +FT.SUGGET/FT.SUGLEN and -XPENDING/TS.INFO/XREAD.get_command_policies(),STATIC_POLICIES, andDEFAULT_ALLOW_LISTare deprecated. Policy types move tometadata.pywith re-exports.RedisCluster._get_command_keysraisesRedisClusterExceptionwhen there is no default node.Reviewed by Cursor Bugbot for commit 5310f9f. Bugbot is set up for automated code reviews on this repo. Configure here.