Skip to content

Conversation

@petyaslavova
Copy link
Collaborator

@petyaslavova petyaslavova commented Nov 14, 2025

This PR improves the Redis cluster's READ_COMMANDS frozenset 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:

  • Find specific commands
  • Add new commands in the future
  • Understand the command categorization
  • Removed deprecated commands: Aligns with Redis 6.2+ best practices

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

@petyaslavova petyaslavova requested a review from Copilot November 14, 2025 11:52
@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label Nov 14, 2025
Copilot finished reviewing on behalf of petyaslavova November 14, 2025 11:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

"MGET",
"PTTL",
"RANDOMKEY",
"LCS",
Copy link

Copilot AI Nov 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
@petyaslavova petyaslavova merged commit 3537352 into master Nov 17, 2025
72 of 73 checks passed
@petyaslavova petyaslavova deleted the ps_extending_read_commands_for_cluster branch November 17, 2025 11:16
petyaslavova added a commit that referenced this pull request Nov 18, 2025
…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
petyaslavova added a commit that referenced this pull request Nov 19, 2025
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance Maintenance (CI, Releases, etc)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature request: JSON.GET in cluster.py READ_COMMANDS

3 participants