Skip to content
This repository was archived by the owner on Feb 21, 2023. It is now read-only.

Commit 8fd5041

Browse files
Support for CLIENT TRACKINFO (redis/redis-py#1560) Signed-off-by: Andrew-Chen-Wang <[email protected]>
1 parent dd35c94 commit 8fd5041

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

aioredis/client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,7 @@ class Redis(Commands):
718718
"CLIENT SETNAME": bool_ok,
719719
"CLIENT UNBLOCK": lambda r: r and int(r) == 1 or False,
720720
"CLIENT PAUSE": bool_ok,
721+
"CLIENT TRACKINGINFO": lambda r: list(map(str_if_bytes, r)),
721722
"CLUSTER ADDSLOTS": bool_ok,
722723
"CLUSTER COUNT-FAILURE-REPORTS": lambda x: int(x),
723724
"CLUSTER COUNTKEYSINSLOT": lambda x: int(x),

aioredis/commands.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,13 @@ def client_id(self: _SELF_ANNOTATION) -> Awaitable:
436436
"""Returns the current connection id"""
437437
return self.execute_command("CLIENT ID")
438438

439+
def client_trackinginfo(self: _SELF_ANNOTATION) -> Awaitable:
440+
"""Returns the information about the current client connection's
441+
use of the server assisted client side cache.
442+
See https://redis.io/commands/client-trackinginfo
443+
"""
444+
return self.execute_command("CLIENT TRACKINGINFO")
445+
439446
def client_setname(self: _SELF_ANNOTATION, name: str) -> Awaitable:
440447
"""Sets the current connection name"""
441448
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
@@ -380,6 +380,12 @@ async def test_client_list_client_id(self, r: aioredis.Redis):
380380
async def test_client_id(self, r: aioredis.Redis):
381381
assert await r.client_id() > 0
382382

383+
@skip_if_server_version_lt('6.2.0')
384+
async def test_client_trackinginfo(self, r: aioredis.Redis):
385+
res = await r.client_trackinginfo()
386+
assert len(res) > 2
387+
assert 'prefixes' in res
388+
383389
@skip_if_server_version_lt("5.0.0")
384390
async def test_client_unblock(self, r: aioredis.Redis):
385391
myid = await r.client_id()

0 commit comments

Comments
 (0)