Skip to content

Commit 874b582

Browse files
committed
Support for command count
Part of redis#1546
1 parent efdba1a commit 874b582

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

redis/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,8 @@ class Redis(Commands, object):
685685
'CLUSTER SET-CONFIG-EPOCH': bool_ok,
686686
'CLUSTER SETSLOT': bool_ok,
687687
'CLUSTER SLAVES': parse_cluster_nodes,
688+
'COMMAND': int,
689+
'COMMAND COUNT': int,
688690
'CONFIG GET': parse_config_get,
689691
'CONFIG RESETSTAT': bool_ok,
690692
'CONFIG SET': bool_ok,

redis/commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2906,6 +2906,9 @@ def module_list(self):
29062906
"""
29072907
return self.execute_command('MODULE LIST')
29082908

2909+
def command_count(self):
2910+
return self.execute_command('COMMAND COUNT')
2911+
29092912

29102913
class Script:
29112914
"An executable Lua script object returned by ``register_script``"

tests/test_commands.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3228,6 +3228,12 @@ def test_module_list(self, r):
32283228
assert isinstance(r.module_list(), list)
32293229
assert not r.module_list()
32303230

3231+
@skip_if_server_version_lt('2.8.13')
3232+
def test_command_count(self, r):
3233+
res = r.command_count()
3234+
assert isinstance(res, int)
3235+
assert res >= 100
3236+
32313237

32323238
class TestBinarySave:
32333239

0 commit comments

Comments
 (0)