Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add client no-touch #2745

Merged
merged 6 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,17 @@ def client_no_evict(self, mode: str) -> Union[Awaitable[str], str]:
"""
return self.execute_command("CLIENT NO-EVICT", mode)

def client_no_touch(self, mode: str) -> Union[Awaitable[str], str]:
"""
# The command controls whether commands sent by the client will alter
# the LRU/LFU of the keys they access.
# When turned on, the current client will not change LFU/LRU stats,
# unless it sends the TOUCH command.

For more information see https://redis.io/commands/client-no-touch
"""
return self.execute_command("CLIENT NO-TOUCH", mode)

def command(self, **kwargs):
"""
Returns dict reply of details about all Redis commands.
Expand Down
8 changes: 8 additions & 0 deletions tests/test_asyncio/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,14 @@ async def test_client_pause(self, r: redis.Redis):
with pytest.raises(exceptions.RedisError):
await r.client_pause(timeout="not an integer")

@skip_if_server_version_lt("7.2.0")
@pytest.mark.onlynoncluster
async def test_client_no_touch(self, r: redis.Redis):
assert await r.client_no_touch("ON") == b"OK"
assert await r.client_no_touch("OFF") == b"OK"
with pytest.raises(TypeError):
await r.client_no_touch()

async def test_config_get(self, r: redis.Redis):
data = await r.config_get()
assert "maxmemory" in data
Expand Down
8 changes: 8 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,14 @@ def test_client_no_evict(self, r):
with pytest.raises(TypeError):
r.client_no_evict()

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("7.2.0")
def test_client_no_touch(self, r):
assert r.client_no_touch("ON") == b"OK"
assert r.client_no_touch("OFF") == b"OK"
with pytest.raises(TypeError):
r.client_no_touch()

@pytest.mark.onlynoncluster
@skip_if_server_version_lt("3.2.0")
def test_client_reply(self, r, r_timeout):
Expand Down