summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeir Shpilraien (Spielrein) <meir@redis.com>2022-02-07 09:46:45 +0200
committerGuy Korland <gkorland@gmail.com>2022-02-08 08:19:06 +0200
commita7626ae0fad90600f526ee1742129a3a3f348e7e (patch)
treee873422907af38ed97c3b77bd906ef85e6fde2b0
parentdf0f9315953c9bfc11c1af0b465734f1b4fa3afb (diff)
downloadredis-py-a7626ae0fad90600f526ee1742129a3a3f348e7e.tar.gz
Fix flushdb and flushall (#1926)
* Fix flushdb and flushall Both commands should be broadcasted to all the shards. * Support ssl_password on cluster * linter fix * change commands to run only on primary nodes Co-authored-by: Chayim I. Kirshen <c@kirshen.com> Co-authored-by: dvora-h <dvora.heller@redis.com> (cherry picked from commit 045d5ed15305ccc44a0330e6f65f669998815598)
-rw-r--r--redis/cluster.py10
-rw-r--r--tests/test_cluster.py7
2 files changed, 15 insertions, 2 deletions
diff --git a/redis/cluster.py b/redis/cluster.py
index 5464723..b594d30 100644
--- a/redis/cluster.py
+++ b/redis/cluster.py
@@ -118,6 +118,7 @@ REDIS_ALLOWED_KEYS = (
"ssl_certfile",
"ssl_cert_reqs",
"ssl_keyfile",
+ "ssl_password",
"unix_socket_path",
"username",
)
@@ -241,8 +242,6 @@ class RedisCluster(RedisClusterCommands):
"SHUTDOWN",
"KEYS",
"SCAN",
- "FLUSHALL",
- "FLUSHDB",
"DBSIZE",
"BGSAVE",
"SLOWLOG GET",
@@ -288,6 +287,13 @@ class RedisCluster(RedisClusterCommands):
),
list_keys_to_dict(
[
+ "FLUSHALL",
+ "FLUSHDB",
+ ],
+ PRIMARIES,
+ ),
+ list_keys_to_dict(
+ [
"CLUSTER COUNTKEYSINSLOT",
"CLUSTER DELSLOTS",
"CLUSTER GETKEYSINSLOT",
diff --git a/tests/test_cluster.py b/tests/test_cluster.py
index 90f52d4..ab98ed5 100644
--- a/tests/test_cluster.py
+++ b/tests/test_cluster.py
@@ -2640,3 +2640,10 @@ class TestClusterMonitor:
r.get(byte_string)
response = wait_for_command(r, m, "GET {foo}bar\\\\x92", key=key)
assert response["command"] == "GET {foo}bar\\\\x92"
+
+ def test_flush(self, r):
+ r.set("x", "1")
+ r.set("z", "1")
+ r.flushall()
+ assert r.get("x") is None
+ assert r.get("y") is None