From 374718f02a2523c73b6dfc83b82e319b2f01aa7b Mon Sep 17 00:00:00 2001 From: "Chayim I. Kirshen" Date: Wed, 1 Sep 2021 13:26:06 +0300 Subject: [PATCH] Support for CLIENT TRACKINFO Part of #1546 --- redis/client.py | 1 + redis/commands.py | 7 +++++++ tests/test_commands.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/redis/client.py b/redis/client.py index a4d7f6b43a..f0eae479af 100755 --- a/redis/client.py +++ b/redis/client.py @@ -669,6 +669,7 @@ class Redis(Commands, object): 'CLIENT SETNAME': bool_ok, 'CLIENT UNBLOCK': lambda r: r and int(r) == 1 or False, 'CLIENT PAUSE': bool_ok, + 'CLIENT TRACKINGINFO': lambda r: list(map(str_if_bytes, r)), 'CLUSTER ADDSLOTS': bool_ok, 'CLUSTER COUNT-FAILURE-REPORTS': lambda x: int(x), 'CLUSTER COUNTKEYSINSLOT': lambda x: int(x), diff --git a/redis/commands.py b/redis/commands.py index 42307799de..9748183cd0 100644 --- a/redis/commands.py +++ b/redis/commands.py @@ -356,6 +356,13 @@ def client_id(self): "Returns the current connection id" return self.execute_command('CLIENT ID') + def client_trackinginfo(self): + """Returns the information about the current client connection's + use of the server assisted client side cache. + See https://redis.io/commands/client-trackinginfo + """ + return self.execute_command('CLIENT TRACKINGINFO') + 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 d77a01c29a..df24c66f33 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -307,6 +307,12 @@ def test_client_list_client_id(self, r): def test_client_id(self, r): assert r.client_id() > 0 + @skip_if_server_version_lt('6.2.0') + def test_client_trackinginfo(self, r): + res = r.client_trackinginfo() + assert len(res) > 2 + assert 'prefixes' in res + @skip_if_server_version_lt('5.0.0') def test_client_unblock(self, r): myid = r.client_id()