summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorItamar Haber <itamar@redislabs.com>2018-10-05 15:31:56 +0300
committerItamar Haber <itamar@redislabs.com>2018-10-05 15:31:56 +0300
commit4cb632a92581002f784e546e5393efa72853112c (patch)
tree13e60f835ae292c4406805efdbfa45f8767d5d16
parent0d6c5f28ef87c83df5540abc358252cae3d2060e (diff)
downloadredis-py-4cb632a92581002f784e546e5393efa72853112c.tar.gz
Adds support for CLIENT ID
Signed-off-by: Itamar Haber <itamar@redislabs.com>
-rwxr-xr-xredis/client.py5
-rw-r--r--tests/test_commands.py4
2 files changed, 9 insertions, 0 deletions
diff --git a/redis/client.py b/redis/client.py
index 79e94d0..53b7cc2 100755
--- a/redis/client.py
+++ b/redis/client.py
@@ -398,6 +398,7 @@ class StrictRedis(object):
string_keys_to_dict('BGREWRITEAOF BGSAVE', lambda r: True),
{
'CLIENT GETNAME': lambda r: r and nativestr(r),
+ 'CLIENT ID': int,
'CLIENT KILL': bool_ok,
'CLIENT LIST': parse_client_list,
'CLIENT SETNAME': bool_ok,
@@ -707,6 +708,10 @@ class StrictRedis(object):
"Returns the current connection name"
return self.execute_command('CLIENT GETNAME')
+ def client_id(self):
+ "Returns the current connection id"
+ return self.execute_command('CLIENT ID')
+
def client_setname(self, name):
"Sets the current connection name"
return self.execute_command('CLIENT SETNAME', name)
diff --git a/tests/test_commands.py b/tests/test_commands.py
index b9b9b66..b8deee6 100644
--- a/tests/test_commands.py
+++ b/tests/test_commands.py
@@ -59,6 +59,10 @@ class TestRedisCommands(object):
assert isinstance(clients[0], dict)
assert 'addr' in clients[0]
+ @skip_if_server_version_lt('5.0.0')
+ def test_client_id(self, r):
+ assert r.client_id() > 0
+
@skip_if_server_version_lt('2.6.9')
def test_client_getname(self, r):
assert r.client_getname() is None