Skip to content

Commit

Permalink
Support for QUIT
Browse files Browse the repository at this point in the history
Part of redis#1546
  • Loading branch information
chayim committed Sep 1, 2021
1 parent efdba1a commit 5a2c4cd
Show file tree
Hide file tree
Showing 3 changed files with 10 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 @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5a2c4cd

Please sign in to comment.