Skip to content

Commit 18c1cc7

Browse files
authored
Support for command count (#1554)
Part of #1546
1 parent de9922a commit 18c1cc7

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

redis/client.py

+2
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

+3
Original file line numberDiff line numberDiff line change
@@ -2924,6 +2924,9 @@ def module_list(self):
29242924
"""
29252925
return self.execute_command('MODULE LIST')
29262926

2927+
def command_count(self):
2928+
return self.execute_command('COMMAND COUNT')
2929+
29272930

29282931
class Script:
29292932
"An executable Lua script object returned by ``register_script``"

tests/test_commands.py

+6
Original file line numberDiff line numberDiff line change
@@ -3240,6 +3240,12 @@ def test_module_list(self, r):
32403240
assert isinstance(r.module_list(), list)
32413241
assert not r.module_list()
32423242

3243+
@skip_if_server_version_lt('2.8.13')
3244+
def test_command_count(self, r):
3245+
res = r.command_count()
3246+
assert isinstance(res, int)
3247+
assert res >= 100
3248+
32433249

32443250
class TestBinarySave:
32453251

0 commit comments

Comments
 (0)