Skip to content

Commit

Permalink
Support for command count
Browse files Browse the repository at this point in the history
Part of redis#1546
  • Loading branch information
chayim committed Sep 1, 2021
1 parent efdba1a commit 874b582
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,8 @@ class Redis(Commands, object):
'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 redis/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2906,6 +2906,9 @@ def module_list(self):
"""
return self.execute_command('MODULE LIST')

def command_count(self):
return self.execute_command('COMMAND COUNT')


class Script:
"An executable Lua script object returned by ``register_script``"
Expand Down
6 changes: 6 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3228,6 +3228,12 @@ def test_module_list(self, r):
assert isinstance(r.module_list(), list)
assert not r.module_list()

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


class TestBinarySave:

Expand Down

0 comments on commit 874b582

Please sign in to comment.