Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 44 additions & 34 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,41 +302,49 @@ class AbstractRedisCluster:
)

SEARCH_COMMANDS = (
[
"FT.CREATE",
"FT.SEARCH",
"FT.AGGREGATE",
"FT.EXPLAIN",
"FT.EXPLAINCLI",
"FT,PROFILE",
"FT.ALTER",
"FT.DROPINDEX",
"FT.ALIASADD",
"FT.ALIASUPDATE",
"FT.ALIASDEL",
"FT.TAGVALS",
"FT.SUGADD",
"FT.SUGGET",
"FT.SUGDEL",
"FT.SUGLEN",
"FT.SYNUPDATE",
"FT.SYNDUMP",
"FT.SPELLCHECK",
"FT.DICTADD",
"FT.DICTDEL",
"FT.DICTDUMP",
"FT.INFO",
"FT._LIST",
"FT.CONFIG",
"FT.ADD",
"FT.DEL",
"FT.DROP",
"FT.GET",
"FT.MGET",
"FT.SYNADD",
],
"FT.CREATE",
"FT.SEARCH",
"FT.AGGREGATE",
"FT.EXPLAIN",
"FT.EXPLAINCLI",
"FT,PROFILE",
"FT.ALTER",
"FT.DROPINDEX",
"FT.ALIASADD",
"FT.ALIASUPDATE",
"FT.ALIASDEL",
"FT.TAGVALS",
"FT.SUGADD",
"FT.SUGGET",
"FT.SUGDEL",
"FT.SUGLEN",
"FT.SYNUPDATE",
"FT.SYNDUMP",
"FT.SPELLCHECK",
"FT.DICTADD",
"FT.DICTDEL",
"FT.DICTDUMP",
"FT.INFO",
"FT._LIST",
"FT.CONFIG",
"FT.ADD",
"FT.DEL",
"FT.DROP",
"FT.GET",
"FT.MGET",
"FT.SYNADD",
)

# The following commands of the TimeSeries module do not operate on
# keys (time series) specified explicitly in their arguments. Instead,
# they operate on keys matched by specified filters (by label, value, etc.)
TIMESERIES_FILTER_COMMANDS = [
"TS.MGET",
"TS.MRANGE",
"TS.MREVRANGE",
"TS.QUERYINDEX",
]

CLUSTER_COMMANDS_RESPONSE_CALLBACKS = {
"CLUSTER SLOTS": parse_cluster_slots,
"CLUSTER SHARDS": parse_cluster_shards,
Expand Down Expand Up @@ -868,7 +876,9 @@ def _determine_nodes(self, *args, **kwargs) -> List["ClusterNode"]:
elif command_flag == self.__class__.DEFAULT_NODE:
# return the cluster's default node
return [self.nodes_manager.default_node]
elif command in self.__class__.SEARCH_COMMANDS[0]:
elif command in self.__class__.SEARCH_COMMANDS:
return [self.nodes_manager.default_node]
elif command in self.__class__.TIMESERIES_FILTER_COMMANDS:
return [self.nodes_manager.default_node]
else:
# get the node that holds the key's slot
Expand Down
5 changes: 3 additions & 2 deletions redis/commands/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ def get_keys(self, redis_conn, *args):
and command["last_key_pos"] == 0
):
is_subcmd = False
if "subcommands" in command:
subcommands = command.get("subcommands")
if subcommands:
subcmd_name = f"{cmd_name}|{args[1].lower()}"
for subcmd in command["subcommands"]:
for subcmd in subcommands:
if str_if_bytes(subcmd[0]) == subcmd_name:
command = self.parse_subcommand(subcmd)
is_subcmd = True
Expand Down