Skip to content

Commit 7f96435

Browse files
authored
CLIENT REDIR command support (#1623)
1 parent 576d33c commit 7f96435

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

redis/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ class Redis(Commands, object):
675675
'CLIENT SETNAME': bool_ok,
676676
'CLIENT UNBLOCK': lambda r: r and int(r) == 1 or False,
677677
'CLIENT PAUSE': bool_ok,
678+
'CLIENT GETREDIR': int,
678679
'CLIENT TRACKINGINFO': lambda r: list(map(str_if_bytes, r)),
679680
'CLUSTER ADDSLOTS': bool_ok,
680681
'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x),

redis/commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,14 @@ def client_getname(self):
377377
"""Returns the current connection name"""
378378
return self.execute_command('CLIENT GETNAME')
379379

380+
def client_getredir(self):
381+
"""Returns the ID (an integer) of the client to whom we are
382+
redirecting tracking notifications.
383+
384+
see: https://redis.io/commands/client-getredir
385+
"""
386+
return self.execute_command('CLIENT GETREDIR')
387+
380388
def client_reply(self, reply):
381389
"""Enable and disable redis server replies.
382390
``reply`` Must be ON OFF or SKIP,

tests/test_commands.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,11 @@ def test_client_reply(self, r, r_timeout):
490490
# validate it was set
491491
assert r.get('foo') == b'bar'
492492

493+
@skip_if_server_version_lt('6.0.0')
494+
def test_client_getredir(self, r):
495+
assert isinstance(r.client_getredir(), int)
496+
assert r.client_getredir() == -1
497+
493498
def test_config_get(self, r):
494499
data = r.config_get()
495500
assert 'maxmemory' in data

0 commit comments

Comments
 (0)