diff options
Diffstat (limited to 'redis/commands/cluster.py')
-rw-r--r-- | redis/commands/cluster.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/redis/commands/cluster.py b/redis/commands/cluster.py index 8e4c8ef..f0eaaf7 100644 --- a/redis/commands/cluster.py +++ b/redis/commands/cluster.py @@ -316,6 +316,25 @@ class AsyncClusterMultiKeyCommands(ClusterMultiKeyCommands): # Sum up the reply from each command return sum(await self._execute_pipeline_by_slot(command, slots_to_keys)) + async def _execute_pipeline_by_slot( + self, command: str, slots_to_args: Mapping[int, Iterable[EncodableT]] + ) -> List[Any]: + if self._initialize: + await self.initialize() + read_from_replicas = self.read_from_replicas and command in READ_COMMANDS + pipe = self.pipeline() + [ + pipe.execute_command( + command, + *slot_args, + target_nodes=[ + self.nodes_manager.get_node_from_slot(slot, read_from_replicas) + ], + ) + for slot, slot_args in slots_to_args.items() + ] + return await pipe.execute() + class ClusterManagementCommands(ManagementCommands): """ |