Skip to content

Commit a7626ae

Browse files
MeirShpilraienchayimdvora-h
authored andcommitted
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 <[email protected]> Co-authored-by: dvora-h <[email protected]> (cherry picked from commit 045d5ed)
1 parent df0f931 commit a7626ae

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

redis/cluster.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def fix_server(*args):
118118
"ssl_certfile",
119119
"ssl_cert_reqs",
120120
"ssl_keyfile",
121+
"ssl_password",
121122
"unix_socket_path",
122123
"username",
123124
)
@@ -241,8 +242,6 @@ class RedisCluster(RedisClusterCommands):
241242
"SHUTDOWN",
242243
"KEYS",
243244
"SCAN",
244-
"FLUSHALL",
245-
"FLUSHDB",
246245
"DBSIZE",
247246
"BGSAVE",
248247
"SLOWLOG GET",
@@ -286,6 +285,13 @@ class RedisCluster(RedisClusterCommands):
286285
],
287286
DEFAULT_NODE,
288287
),
288+
list_keys_to_dict(
289+
[
290+
"FLUSHALL",
291+
"FLUSHDB",
292+
],
293+
PRIMARIES,
294+
),
289295
list_keys_to_dict(
290296
[
291297
"CLUSTER COUNTKEYSINSLOT",

tests/test_cluster.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,3 +2640,10 @@ def test_command_with_escaped_data(self, r):
26402640
r.get(byte_string)
26412641
response = wait_for_command(r, m, "GET {foo}bar\\\\x92", key=key)
26422642
assert response["command"] == "GET {foo}bar\\\\x92"
2643+
2644+
def test_flush(self, r):
2645+
r.set("x", "1")
2646+
r.set("z", "1")
2647+
r.flushall()
2648+
assert r.get("x") is None
2649+
assert r.get("y") is None

0 commit comments

Comments
 (0)