@@ -25,6 +25,21 @@ def initialize(self, r):
2525 commands [cmd .lower ()] =  commands .pop (cmd )
2626 self .commands  =  commands 
2727
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+ 
2843 # As soon as this PR is merged into Redis, we should reimplement 
2944 # our logic to use COMMAND INFO changes to determine the key positions 
3045 # https://github.com/redis/redis/pull/8324 
@@ -72,8 +87,17 @@ def get_keys(self, redis_conn, *args):
7287 and  command ["first_key_pos" ] ==  0 
7388 and  command ["last_key_pos" ] ==  0 
7489 ):
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+ 
7598 # The command doesn't have keys in it 
76-  return  None 
99+  if  not  is_subcmd :
100+  return  None 
77101 last_key_pos  =  command ["last_key_pos" ]
78102 if  last_key_pos  <  0 :
79103 last_key_pos  =  len (args ) -  abs (last_key_pos )
0 commit comments