summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-12-22 11:52:25 +0200
committerGitHub <noreply@github.com>2021-12-22 11:52:25 +0200
commit989d06d0832c2cccdb5b74f1b2afab2b2441fc79 (patch)
treeaaf5c46b9fd86cec5f0f799d090c991f17275506
parent139bcbb07e7bc45a4762c7bcb17f4e80235ef8f8 (diff)
downloadredis-py-989d06d0832c2cccdb5b74f1b2afab2b2441fc79.tar.gz
Support for RESET command since Redis 6.2.0 (#1824)
-rwxr-xr-xredis/client.py1
-rw-r--r--redis/commands/core.py7
-rw-r--r--tests/test_commands.py5
3 files changed, 13 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index 16ffbb0..c7aa17b 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -768,6 +768,7 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
"STRALGO": parse_stralgo,
"PUBSUB NUMSUB": parse_pubsub_numsub,
"RANDOMKEY": lambda r: r and r or None,
+ "RESET": str_if_bytes,
"SCAN": parse_scan,
"SCRIPT EXISTS": lambda r: list(map(bool, r)),
"SCRIPT FLUSH": bool_ok,
diff --git a/redis/commands/core.py b/redis/commands/core.py
index 2dd7c10..0823315 100644
--- a/redis/commands/core.py
+++ b/redis/commands/core.py
@@ -817,6 +817,13 @@ class ManagementCommands:
else:
return self.execute_command("LOLWUT", **kwargs)
+ def reset(self):
+ """Perform a full reset on the connection's server side contenxt.
+
+ See: https://redis.io/commands/reset
+ """
+ return self.execute_command("RESET")
+
def migrate(
self,
host,
diff --git a/tests/test_commands.py b/tests/test_commands.py
index f918043..0912161 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -669,6 +669,11 @@ class TestRedisCommands:
lolwut = r.lolwut(5, 6, 7, 8).decode("utf-8")
assert "Redis ver." in lolwut
+ @pytest.mark.onlynoncluster
+ @skip_if_server_version_lt("6.2.0")
+ def test_reset(self, r):
+ assert r.reset() == "RESET"
+
def test_object(self, r):
r["a"] = "foo"
assert isinstance(r.object("refcount", "a"), int)