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

Commit

Permalink
Browse files Browse the repository at this point in the history
Support for command count (redis/redis-py#1554)

Signed-off-by: Andrew-Chen-Wang <acwangpython@gmail.com>
  • Loading branch information
Andrew-Chen-Wang committed Oct 8, 2021
1 parent 6cc5b45 commit 5fa58b7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions aioredis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,8 @@ class Redis(Commands):
"CLUSTER SET-CONFIG-EPOCH": bool_ok,
"CLUSTER SETSLOT": bool_ok,
"CLUSTER SLAVES": parse_cluster_nodes,
"COMMAND": int,
"COMMAND COUNT": int,
"CONFIG GET": parse_config_get,
"CONFIG RESETSTAT": bool_ok,
"CONFIG SET": bool_ok,
Expand Down
3 changes: 3 additions & 0 deletions aioredis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3505,6 +3505,9 @@ def module_unload(self: _SELF_ANNOTATION, name: str) -> Awaitable:
"""
return self.execute_command("MODULE UNLOAD", name)

def command_count(self: _SELF_ANNOTATION) -> Awaitable:
return self.execute_command("COMMAND COUNT")

def module_list(self: _SELF_ANNOTATION) -> Awaitable:
"""
Returns a list of dictionaries containing the name and version of
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3503,6 +3503,12 @@ async def test_module_list(self, r: aioredis.Redis):
assert isinstance(await r.module_list(), list)
assert not await r.module_list()

@skip_if_server_version_lt('2.8.13')
async def test_command_count(self, r: aioredis.Redis):
res = await r.command_count()
assert isinstance(res, int)
assert res >= 100


class TestBinarySave:
async def test_binary_get_set(self, r: aioredis.Redis):
Expand Down

0 comments on commit 5fa58b7

Please sign in to comment.