Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for command count #1554

Merged
merged 1 commit into from
Sep 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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