From 5a2c4cdc0b580e51e3a401eb2e9cf517312642f3 Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Wed, 1 Sep 2021 11:52:03 +0300 Subject: [PATCH] Support for QUIT Part of #1546 --- redis/client.py | 1 + redis/commands.py | 6 ++++++ tests/test_commands.py | 3 +++ 3 files changed, 10 insertions(+) diff --git a/redis/client.py b/redis/client.py index 4a9e33a21e..828c45a90e 100755 --- a/redis/client.py +++ b/redis/client.py @@ -707,6 +707,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 29877dbef9..915dabf7f1 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -535,6 +535,12 @@ def ping(self): "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 0c9ca1eb57..dc8c210e5d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -478,6 +478,9 @@ def test_object(self, r): 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)