summaryrefslogtreecommitdiff
path: root/redis/cluster.py
diff options
context:
space:
mode:
authorUtkarsh Gupta <utkarshgupta137@gmail.com>2022-03-23 14:48:16 +0530
committerGitHub <noreply@github.com>2022-03-23 11:18:16 +0200
commit827dcde5c0af5f7aa9bdc3999fc86aa2ba945118 (patch)
tree2a7bf80c18b3c2eb391a779c0a4c965076114f7e /redis/cluster.py
parent032fd227d3325a24a47b9d33fc42bccaafba28e2 (diff)
downloadredis-py-827dcde5c0af5f7aa9bdc3999fc86aa2ba945118.tar.gz
[CLUSTER] Fix scan command cursors & Fix scan_iter (#2054)
* cluster/scan: fix return cursor & change default node to primaries * cluster/scan_iter: fix iteration Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
Diffstat (limited to 'redis/cluster.py')
-rw-r--r--redis/cluster.py16
1 files changed, 10 insertions, 6 deletions
diff --git a/redis/cluster.py b/redis/cluster.py
index 287fd4f..221df85 100644
--- a/redis/cluster.py
+++ b/redis/cluster.py
@@ -7,7 +7,7 @@ import threading
import time
from collections import OrderedDict
-from redis.client import CaseInsensitiveDict, PubSub, Redis
+from redis.client import CaseInsensitiveDict, PubSub, Redis, parse_scan
from redis.commands import CommandsParser, RedisClusterCommands
from redis.connection import ConnectionPool, DefaultParser, Encoder, parse_url
from redis.crc import REDIS_CLUSTER_HASH_SLOTS, key_slot
@@ -51,10 +51,14 @@ def get_connection(redis_node, *args, **options):
def parse_scan_result(command, res, **options):
- keys_list = []
- for primary_res in res.values():
- keys_list += primary_res[1]
- return 0, keys_list
+ cursors = {}
+ ret = []
+ for node_name, response in res.items():
+ cursor, r = parse_scan(response, **options)
+ cursors[node_name] = cursor
+ ret += r
+
+ return cursors, ret
def parse_pubsub_numsub(command, res, **options):
@@ -244,7 +248,6 @@ class RedisCluster(RedisClusterCommands):
"INFO",
"SHUTDOWN",
"KEYS",
- "SCAN",
"DBSIZE",
"BGSAVE",
"SLOWLOG GET",
@@ -298,6 +301,7 @@ class RedisCluster(RedisClusterCommands):
"FUNCTION LIST",
"FUNCTION LOAD",
"FUNCTION RESTORE",
+ "SCAN",
"SCRIPT EXISTS",
"SCRIPT FLUSH",
"SCRIPT LOAD",