summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-09-01 12:08:38 +0300
committerGitHub <noreply@github.com>2021-09-01 12:08:38 +0300
commit879584b7a359cfd7eeb008b41ba9ca9be16e6633 (patch)
treea0325d4ebdd7d266427d77025bd5fb0c42e3b968
parent9f64c56e0f6994df0609a803e613a055ee57a7cd (diff)
downloadredis-py-879584b7a359cfd7eeb008b41ba9ca9be16e6633.tar.gz
Support for QUIT (#1557)
Part of #1546
-rwxr-xr-xredis/client.py1
-rw-r--r--redis/commands.py6
-rw-r--r--tests/test_commands.py3
3 files changed, 10 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index ef37506..a4d7f6b 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -709,6 +709,7 @@ class Redis(Commands, object):
'MODULE LIST': lambda r: [pairs_to_dict(m) for m in r],
'OBJECT': parse_object,
'PING': lambda r: str_if_bytes(r) == 'PONG',
+ 'QUIT': bool_ok,
'STRALGO': parse_stralgo,
'PUBSUB NUMSUB': parse_pubsub_numsub,
'RANDOMKEY': lambda r: r and r or None,
diff --git a/redis/commands.py b/redis/commands.py
index e1f7368..4230779 100644
--- a/redis/commands.py
+++ b/redis/commands.py
@@ -538,6 +538,12 @@ class Commands:
"Ping the Redis server"
return self.execute_command('PING')
+ def quit(self):
+ """Ask the server to close the connection.
+ https://redis.io/commands/quit
+ """
+ return self.execute_command('QUIT')
+
def save(self):
"""
Tell the Redis server to save its data to disk,
diff --git a/tests/test_commands.py b/tests/test_commands.py
index 1a34712..d77a01c 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -478,6 +478,9 @@ class TestRedisCommands:
def test_ping(self, r):
assert r.ping()
+ def test_quit(self, r):
+ assert r.quit()
+
def test_slowlog_get(self, r, slowlog):
assert r.slowlog_reset()
unicode_string = chr(3456) + 'abcd' + chr(3421)