Skip to content

CLIENT REDIR command support #1623

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,7 @@ class Redis(Commands, object):
'CLIENT SETNAME': bool_ok,
'CLIENT UNBLOCK': lambda r: r and int(r) == 1 or False,
'CLIENT PAUSE': bool_ok,
'CLIENT GETREDIR': int,
'CLIENT TRACKINGINFO': lambda r: list(map(str_if_bytes, r)),
'CLUSTER ADDSLOTS': bool_ok,
'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x),
Expand Down
8 changes: 8 additions & 0 deletions redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ def client_getname(self):
"""Returns the current connection name"""
return self.execute_command('CLIENT GETNAME')

def client_getredir(self):
"""Returns the ID (an integer) of the client to whom we are
redirecting tracking notifications.

see: https://redis.io/commands/client-getredir
"""
return self.execute_command('CLIENT GETREDIR')

def client_reply(self, reply):
"""Enable and disable redis server replies.
``reply`` Must be ON OFF or SKIP,
Expand Down
5 changes: 5 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,11 @@ def test_client_reply(self, r, r_timeout):
# validate it was set
assert r.get('foo') == b'bar'

@skip_if_server_version_lt('6.0.0')
def test_client_getredir(self, r):
assert isinstance(r.client_getredir(), int)
assert r.client_getredir() == -1

def test_config_get(self, r):
data = r.config_get()
assert 'maxmemory' in data
Expand Down