We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 013fef0 + fbb232e commit f8fc065Copy full SHA for f8fc065
tests/test_commands.py
@@ -1320,6 +1320,26 @@ def test_get_and_set(self, r):
1320
assert r.get("integer") == str(integer).encode()
1321
assert r.get("unicode_string").decode("utf-8") == unicode_string
1322
1323
+ def test_set_options_mutually_exclusive(self, r):
1324
+ with pytest.raises(exceptions.DataError):
1325
+ r.set("test", 1, ex=1, px=1)
1326
+
1327
1328
+ r.set("test2", 2, exat=3, pxat=5)
1329
1330
1331
+ r.set("test3", 3, ex=5, exat=1)
1332
1333
+ def test_set_options_type_check(self, r):
1334
1335
+ r.set("test", 1, ex="hi")
1336
1337
1338
+ r.set("test1", 3, px=object())
1339
1340
1341
+ r.set("test3", 1, pxat=3j)
1342
1343
@skip_if_server_version_lt("6.2.0")
1344
def test_getdel(self, r):
1345
assert r.getdel("a") is None
valkey/commands/core.py
@@ -2287,6 +2287,11 @@ def set(
2287
2288
For more information see https://valkey.io/commands/set
2289
"""
2290
+ params = sum(op is not None for op in [ex, px, exat, pxat])
2291
+ if params > 1:
2292
+ raise DataError(
2293
+ "``ex``, ``px``, ``exat`` and ``pxat`` " "are mutually exclusive."
2294
+ )
2295
pieces: list[EncodableT] = [name, value]
2296
options = {}
2297
if ex is not None:
0 commit comments