diff options
author | Utkarsh Gupta <utkarshgupta137@gmail.com> | 2022-03-23 14:48:16 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-23 11:18:16 +0200 |
commit | 827dcde5c0af5f7aa9bdc3999fc86aa2ba945118 (patch) | |
tree | 2a7bf80c18b3c2eb391a779c0a4c965076114f7e /redis/cluster.py | |
parent | 032fd227d3325a24a47b9d33fc42bccaafba28e2 (diff) | |
download | redis-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.py | 16 |
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", |