Skip to content

Commit 9f8e57a

Browse files
async_cluster/parser: optimize _get_moveable_keys
1 parent daf56d5 commit 9f8e57a

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

redis/asyncio/parser.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ async def get_keys(
5353
except KeyError:
5454
# try to split the command name and to take only the main command
5555
# e.g. 'memory' for 'memory usage'
56-
cmd_name_split = args[0].split()
57-
cmd_name = cmd_name_split[0]
58-
if cmd_name in self.commands:
59-
# save the splitted command to args
60-
args = cmd_name_split + list(args[1:])
61-
else:
56+
args = args[0].split() + list(args[1:])
57+
cmd_name = args[0]
58+
if cmd_name not in self.commands:
6259
# We'll try to reinitialize the commands cache, if the engine
6360
# version has changed, the commands may not be current
6461
await self.initialize(redis_conn)
@@ -84,14 +81,8 @@ async def get_keys(
8481
async def _get_moveable_keys(
8582
self, redis_conn: "ClusterNode", *args
8683
) -> Optional[List[str]]:
87-
pieces = []
88-
cmd_name = args[0]
89-
# The command name should be splitted into separate arguments,
90-
# e.g. 'MEMORY USAGE' will be splitted into ['MEMORY', 'USAGE']
91-
pieces = pieces + cmd_name.split()
92-
pieces = pieces + list(args[1:])
9384
try:
94-
keys = await redis_conn.execute_command("COMMAND GETKEYS", *pieces)
85+
keys = await redis_conn.execute_command("COMMAND GETKEYS", *args)
9586
except ResponseError as e:
9687
message = e.__str__()
9788
if (

0 commit comments

Comments
 (0)