Skip to content

Commit

Permalink
Support for RESET command since Redis 6.2.0
Browse files Browse the repository at this point in the history
part of redis#1546
  • Loading branch information
chayim committed Dec 22, 2021
1 parent e0d3ba5 commit 7ba3ce6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,13 @@ def lolwut(self, *version_numbers, **kwargs):
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,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,11 @@ def test_lolwut(self, r):
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)
Expand Down

0 comments on commit 7ba3ce6

Please sign in to comment.