@@ -25,6 +25,21 @@ def initialize(self, r):
25
25
commands [cmd .lower ()] = commands .pop (cmd )
26
26
self .commands = commands
27
27
28
+ def parse_subcommand (self , command , ** options ):
29
+ cmd_dict = {}
30
+ cmd_name = str_if_bytes (command [0 ])
31
+ cmd_dict ["name" ] = cmd_name
32
+ cmd_dict ["arity" ] = int (command [1 ])
33
+ cmd_dict ["flags" ] = [str_if_bytes (flag ) for flag in command [2 ]]
34
+ cmd_dict ["first_key_pos" ] = command [3 ]
35
+ cmd_dict ["last_key_pos" ] = command [4 ]
36
+ cmd_dict ["step_count" ] = command [5 ]
37
+ if len (command ) > 7 :
38
+ cmd_dict ["tips" ] = command [7 ]
39
+ cmd_dict ["key_specifications" ] = command [8 ]
40
+ cmd_dict ["subcommands" ] = command [9 ]
41
+ return cmd_dict
42
+
28
43
# As soon as this PR is merged into Redis, we should reimplement
29
44
# our logic to use COMMAND INFO changes to determine the key positions
30
45
# https://github.com/redis/redis/pull/8324
@@ -72,8 +87,17 @@ def get_keys(self, redis_conn, *args):
72
87
and command ["first_key_pos" ] == 0
73
88
and command ["last_key_pos" ] == 0
74
89
):
90
+ is_subcmd = False
91
+ if "subcommands" in command :
92
+ subcmd_name = f"{ cmd_name } |{ args [1 ].lower ()} "
93
+ for subcmd in command ["subcommands" ]:
94
+ if str_if_bytes (subcmd [0 ]) == subcmd_name :
95
+ command = self .parse_subcommand (subcmd )
96
+ is_subcmd = True
97
+
75
98
# The command doesn't have keys in it
76
- return None
99
+ if not is_subcmd :
100
+ return None
77
101
last_key_pos = command ["last_key_pos" ]
78
102
if last_key_pos < 0 :
79
103
last_key_pos = len (args ) - abs (last_key_pos )
0 commit comments