From 0567fd88619cbcccb85c9e2760e020edeb3190e3 Mon Sep 17 00:00:00 2001 From: dvora-h <67596500+dvora-h@users.noreply.github.com> Date: Wed, 2 Feb 2022 12:52:37 +0200 Subject: [PATCH] add client no-evict (#1856) --- redis/commands/core.py | 8 ++++++++ tests/test_commands.py | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/redis/commands/core.py b/redis/commands/core.py index 17194c341f..b06bb5c941 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -640,6 +640,14 @@ def client_unpause(self, **kwargs): """ return self.execute_command("CLIENT UNPAUSE", **kwargs) + def client_no_evict(self, mode: str) -> str: + """ + Sets the client eviction mode for the current connection. + + For more information check https://redis.io/commands/client-no-evict + """ + return self.execute_command("CLIENT NO-EVICT", mode) + def command(self, **kwargs): """ Returns dict reply of details about all Redis commands. diff --git a/tests/test_commands.py b/tests/test_commands.py index 937172a195..cdcf1202d8 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -592,6 +592,13 @@ def test_client_pause_all(self, r, r2): def test_client_unpause(self, r): assert r.client_unpause() == b"OK" + @pytest.mark.onlynoncluster + # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release + def test_client_no_evict(self, unstable_r): + assert unstable_r.client_no_evict("ON") == b"OK" + with pytest.raises(TypeError): + unstable_r.client_no_evict() + @pytest.mark.onlynoncluster @skip_if_server_version_lt("3.2.0") def test_client_reply(self, r, r_timeout):