Skip to content

Commit 8c06d67

Browse files
aciddustdvora-h
andauthored
Add client no-touch (redis#2745)
* Add client no-touch * Update redis/commands/core.py Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com> * Update test_commands.py Improve test_client_no_touch * Update test_commands.py Add async version test case * Chore remove whitespace Oops --------- Co-authored-by: dvora-h <67596500+dvora-h@users.noreply.github.com>
1 parent c0833f6 commit 8c06d67

File tree

3 files changed

+27
-0
lines changed

3 files changed

+27
-0
lines changed

redis/commands/core.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,17 @@ def client_no_evict(self, mode: str) -> Union[Awaitable[str], str]:
761761
"""
762762
return self.execute_command("CLIENT NO-EVICT", mode)
763763

764+
def client_no_touch(self, mode: str) -> Union[Awaitable[str], str]:
765+
"""
766+
# The command controls whether commands sent by the client will alter
767+
# the LRU/LFU of the keys they access.
768+
# When turned on, the current client will not change LFU/LRU stats,
769+
# unless it sends the TOUCH command.
770+
771+
For more information see https://redis.io/commands/client-no-touch
772+
"""
773+
return self.execute_command("CLIENT NO-TOUCH", mode)
774+
764775
def command(self, **kwargs):
765776
"""
766777
Returns dict reply of details about all Redis commands.

tests/test_asyncio/test_commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,14 @@ async def test_client_pause(self, r: redis.Redis):
453453
with pytest.raises(exceptions.RedisError):
454454
await r.client_pause(timeout="not an integer")
455455

456+
@skip_if_server_version_lt("7.2.0")
457+
@pytest.mark.onlynoncluster
458+
async def test_client_no_touch(self, r: redis.Redis):
459+
assert await r.client_no_touch("ON") == b"OK"
460+
assert await r.client_no_touch("OFF") == b"OK"
461+
with pytest.raises(TypeError):
462+
await r.client_no_touch()
463+
456464
async def test_config_get(self, r: redis.Redis):
457465
data = await r.config_get()
458466
assert "maxmemory" in data

tests/test_commands.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,14 @@ def test_client_no_evict(self, r):
696696
with pytest.raises(TypeError):
697697
r.client_no_evict()
698698

699+
@pytest.mark.onlynoncluster
700+
@skip_if_server_version_lt("7.2.0")
701+
def test_client_no_touch(self, r):
702+
assert r.client_no_touch("ON") == b"OK"
703+
assert r.client_no_touch("OFF") == b"OK"
704+
with pytest.raises(TypeError):
705+
r.client_no_touch()
706+
699707
@pytest.mark.onlynoncluster
700708
@skip_if_server_version_lt("3.2.0")
701709
def test_client_reply(self, r, r_timeout):

0 commit comments

Comments
 (0)