Skip to content

Commit 51516cb

Browse files
authored
Support for CLIENT TRACKINFO (#1560)
Part of #1546
1 parent 0f8d0dc commit 51516cb

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
@@ -674,6 +674,7 @@ class Redis(Commands, object):
674674
'CLIENT SETNAME': bool_ok,
675675
'CLIENT UNBLOCK': lambda r: r and int(r) == 1 or False,
676676
'CLIENT PAUSE': bool_ok,
677+
'CLIENT TRACKINGINFO': lambda r: list(map(str_if_bytes, r)),
677678
'CLUSTER ADDSLOTS': bool_ok,
678679
'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x),
679680
'CLUSTER COUNTKEYSINSLOT': lambda x: int(x),

redis/commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,13 @@ def client_id(self):
369369
"Returns the current connection id"
370370
return self.execute_command('CLIENT ID')
371371

372+
def client_trackinginfo(self):
373+
"""Returns the information about the current client connection's
374+
use of the server assisted client side cache.
375+
See https://redis.io/commands/client-trackinginfo
376+
"""
377+
return self.execute_command('CLIENT TRACKINGINFO')
378+
372379
def client_setname(self, name):
373380
"Sets the current connection name"
374381
return self.execute_command('CLIENT SETNAME', name)

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,12 @@ def test_client_list_client_id(self, r):
315315
def test_client_id(self, r):
316316
assert r.client_id() > 0
317317

318+
@skip_if_server_version_lt('6.2.0')
319+
def test_client_trackinginfo(self, r):
320+
res = r.client_trackinginfo()
321+
assert len(res) > 2
322+
assert 'prefixes' in res
323+
318324
@skip_if_server_version_lt('5.0.0')
319325
def test_client_unblock(self, r):
320326
myid = r.client_id()

0 commit comments

Comments
 (0)