Skip to content

Commit 989d06d

Browse files
authored
Support for RESET command since Redis 6.2.0 (#1824)
1 parent 139bcbb commit 989d06d

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

redis/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ class Redis(RedisModuleCommands, CoreCommands, SentinelCommands):
768768
"STRALGO": parse_stralgo,
769769
"PUBSUB NUMSUB": parse_pubsub_numsub,
770770
"RANDOMKEY": lambda r: r and r or None,
771+
"RESET": str_if_bytes,
771772
"SCAN": parse_scan,
772773
"SCRIPT EXISTS": lambda r: list(map(bool, r)),
773774
"SCRIPT FLUSH": bool_ok,

redis/commands/core.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,13 @@ def lolwut(self, *version_numbers, **kwargs):
817817
else:
818818
return self.execute_command("LOLWUT", **kwargs)
819819

820+
def reset(self):
821+
"""Perform a full reset on the connection's server side contenxt.
822+
823+
See: https://redis.io/commands/reset
824+
"""
825+
return self.execute_command("RESET")
826+
820827
def migrate(
821828
self,
822829
host,

tests/test_commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,11 @@ def test_lolwut(self, r):
669669
lolwut = r.lolwut(5, 6, 7, 8).decode("utf-8")
670670
assert "Redis ver." in lolwut
671671

672+
@pytest.mark.onlynoncluster
673+
@skip_if_server_version_lt("6.2.0")
674+
def test_reset(self, r):
675+
assert r.reset() == "RESET"
676+
672677
def test_object(self, r):
673678
r["a"] = "foo"
674679
assert isinstance(r.object("refcount", "a"), int)

0 commit comments

Comments
 (0)