Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -760,12 +760,18 @@ def config_get(self, pattern: PatternT = "*", **kwargs) -> ResponseT:
"""
return self.execute_command("CONFIG GET", pattern, **kwargs)

def config_set(self, name: KeyT, value: EncodableT, **kwargs) -> ResponseT:
def config_set(
self,
name: KeyT,
value: EncodableT,
*args: List[Union[KeyT, EncodableT]],
**kwargs,
) -> ResponseT:
"""Set config item ``name`` with ``value``

For more information see https://redis.io/commands/config-set
"""
return self.execute_command("CONFIG SET", name, value, **kwargs)
return self.execute_command("CONFIG SET", name, value, *args, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clean.


def config_resetstat(self, **kwargs) -> ResponseT:
"""
Expand Down
10 changes: 10 additions & 0 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,16 @@ def test_config_set(self, r):
assert r.config_set("timeout", 0)
assert r.config_get()["timeout"] == "0"

@skip_if_server_version_lt("7.0.0")
@skip_if_redis_enterprise()
def test_config_set_multi_params(self, r: redis.Redis):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a lazy, future option for writing tests like this (psuedocode). It comes from a pattern used in go:

x = [('timeout', 70), ('maxmemory', 100)] r.config_set(*x) for y in x: assert r.config_get(x[0]) == x[1] 
r.config_set("timeout", 70, "maxmemory", 100)
assert r.config_get()["timeout"] == "70"
assert r.config_get()["maxmemory"] == "100"
assert r.config_set("timeout", 0, "maxmemory", 0)
assert r.config_get()["timeout"] == "0"
assert r.config_get()["maxmemory"] == "0"

@skip_if_server_version_lt("6.0.0")
@skip_if_redis_enterprise()
def test_failover(self, r):
Expand Down