Expand cluster READ_COMMANDS with additional read-only commands and reorganize the list of commands by category#3845
Conversation
…luster replica nodes
There was a problem hiding this comment.
Pull Request Overview
This PR modernizes and expands the Redis cluster's READ_COMMANDS frozenset by adding 5 new read-only commands, removing 2 deprecated commands, and reorganizing all commands into 12 logical categories for better maintainability.
Key changes:
- Adds PEXPIRETIME, SCAN, TYPE, LPOS, and LCS as read-only commands for improved cluster replica routing
- Removes deprecated GEORADIUS and GEORADIUSBYMEMBER commands (replaced by GEOSEARCH in Redis 6.2+)
- Reorganizes commands into categorized sections with inline comments (Bit Operations, Scripting, Key Operations, String Operations, Geo Operations, Hash Operations, List Operations, Set Operations, Sorted Set Operations, Stream Operations, JSON Module, and RediSearch Module)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
redis/commands/cluster.py
Outdated
| "MGET", | ||
| "PTTL", | ||
| "RANDOMKEY", | ||
| "LCS", |
There was a problem hiding this comment.
LCS (Longest Common Subsequence) is a string operation command that compares two string keys, not a list operation. According to the Redis documentation and the implementation in BasicKeyCommands class (not ListCommands), it should be categorized under "String Operations" instead of "List Operations".
Suggestion: Move LCS from line 106 to the String Operations section (after line 80).
…eorganize the list of commands by category (#3845) * Updating the list with commands allowed to be sent to the read-only cluster replica nodes * Applying review comment
…eorganize the list of commands by category (#3845) * Updating the list with commands allowed to be sent to the read-only cluster replica nodes * Applying review comment
This PR improves the Redis cluster's
READ_COMMANDSfrozenset by:Adding existing read-only commands that are exposed in redis-py but were missing from the cluster routing list.
Reorganizing the entire list into 12 logical sections with inline comments for better maintainability:
Bit Operations (3 commands)
Scripting (3 commands)
Key Operations (9 commands)
String Operations (5 commands)
Geo Operations (4 commands)
Hash Operations (14 commands)
List Operations (5 commands)
Set Operations (10 commands)
Sorted Set Operations (19 commands)
Stream Operations (5 commands)
JSON Module (9 commands)
RediSearch Module (4 commands)
Removing deprecated commands:
GEORADIUS - Deprecated in Redis 6.2 (use GEOSEARCH instead)
GEORADIUSBYMEMBER - Deprecated in Redis 6.2 (use GEOSEARCH instead)
Impact
Improved cluster replica routing: 5 additional read-only commands can now be safely routed to replica nodes for load distribution
Better code organization: Commands are now grouped by data type/module, making it easier to:
Testing
The changes maintain backward compatibility as they only add new commands to the read-only set and reorganize existing ones. No API changes or breaking changes.
This PR addresses the issue where the cluster's READ_COMMANDS list was severely outdated and missing many read-only operations that could safely be executed on replicas.
Fixes #2802