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

Commit b7ede71

Browse files
client_list (redis/redis-py#1517) Signed-off-by: Andrew-Chen-Wang <[email protected]>
1 parent a389184 commit b7ede71

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

aioredis/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ def parse_client_info(value):
581581
"key1=value1 key2=value2 key3=value3"
582582
"""
583583
client_info = {}
584-
infos = value.split(" ")
584+
infos = str_if_bytes(value).split(" ")
585585
for info in infos:
586586
key, value = info.split("=")
587587
client_info[key] = value
@@ -598,8 +598,10 @@ def parse_client_info(value):
598598
"qbuf",
599599
"qbuf-free",
600600
"obl",
601+
"argv-mem",
601602
"oll",
602603
"omem",
604+
"tot-mem",
603605
}:
604606
client_info[int_key] = int(client_info[int_key])
605607
return client_info
@@ -695,6 +697,7 @@ class Redis:
695697
"CLIENT ID": int,
696698
"CLIENT KILL": parse_client_kill,
697699
"CLIENT LIST": parse_client_list,
700+
"CLIENT INFO": parse_client_info,
698701
"CLIENT SETNAME": bool_ok,
699702
"CLIENT UNBLOCK": lambda r: r and int(r) == 1 or False,
700703
"CLIENT PAUSE": bool_ok,
@@ -1391,6 +1394,13 @@ def client_kill_filter(
13911394
)
13921395
return self.execute_command("CLIENT KILL", *args)
13931396

1397+
def client_info(self) -> Awaitable:
1398+
"""
1399+
Returns information and statistics about the current
1400+
client connection.
1401+
"""
1402+
return self.execute_command("CLIENT INFO")
1403+
13941404
def client_list(self, _type: Optional[str] = None) -> Awaitable:
13951405
"""
13961406
Returns a list of currently connected clients.

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,12 @@ async def test_client_list(self, r: aioredis.Redis):
345345
assert isinstance(clients[0], dict)
346346
assert "addr" in clients[0]
347347

348+
@skip_if_server_version_lt("6.2.0")
349+
def test_client_info(self, r: aioredis.Redis):
350+
info = r.client_info()
351+
assert isinstance(info, dict)
352+
assert "addr" in info
353+
348354
@skip_if_server_version_lt("5.0.0")
349355
async def test_client_list_type(self, r: aioredis.Redis):
350356
with pytest.raises(exceptions.RedisError):

0 commit comments

Comments
 (0)