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.
1 parent 231d402 commit 9328025Copy full SHA for 9328025
redis/commands/core.py
@@ -1926,6 +1926,19 @@ def brpoplpush(self, src, dst, timeout=0):
1926
timeout = 0
1927
return self.execute_command("BRPOPLPUSH", src, dst, timeout)
1928
1929
+ def lmpop(self, num_keys, keys, *args, count=1):
1930
+ """
1931
+ Pop ``count`` values (default 1) first non-empty list key from the list
1932
+ of provided key names.
1933
+
1934
+ For more information check https://redis.io/commands/lmpop
1935
1936
+ args = [num_keys] + list_or_args(keys, args)
1937
+ if count != 1:
1938
+ args.extend(["COUNT", count])
1939
1940
+ return self.execute_command("LMPOP", *args)
1941
1942
def lindex(self, name, index):
1943
"""
1944
Return the item from list ``name`` at position ``index``
tests/conftest.py
@@ -15,6 +15,7 @@
15
REDIS_INFO = {}
16
default_redis_url = "redis://localhost:6379/9"
17
default_redismod_url = "redis://localhost:36379"
18
+default_redis_unstable_url = "redis://localhost:6378"
19
20
# default ssl client ignores verification for the purpose of testing
21
default_redis_ssl_url = "rediss://localhost:6666"
@@ -54,6 +55,14 @@ def pytest_addoption(parser):
54
55
" defaults to `%(default)s`",
56
)
57
58
+ parser.addoption(
59
+ "--redis-unstable-url",
60
+ default=default_redis_unstable_url,
61
+ action="store",
62
+ help="Redis unstable (latest version) connection string "
63
+ "defaults to %(default)s`",
64
+ )
65
66
67
def _get_info(redis_url):
68
client = redis.Redis.from_url(redis_url)
@@ -357,6 +366,13 @@ def master_host(request):
357
366
yield parts.hostname, parts.port
358
367
359
368
369
+@pytest.fixture()
370
+def unstable_r(request):
371
+ url = request.config.getoption("--redis-unstable-url")
372
+ with _get_client(redis.Redis, request, from_url=url) as client:
373
+ yield client
374
375
360
376
def wait_for_command(client, monitor, command, key=None):
361
377
# issue a command with a key name that's local to this process.
362
378
# if we find a command with our key before the command we're waiting
tests/test_commands.py
@@ -1473,6 +1473,17 @@ def test_brpoplpush_empty_string(self, r):
1473
r.rpush("a", "")
1474
assert r.brpoplpush("a", "b") == b""
1475
1476
+ @pytest.mark.onlynoncluster
1477
+ # @skip_if_server_version_lt("7.0.0") turn on after redis 7 release
1478
+ def test_lmpop(self, unstable_r):
1479
+ unstable_r.rpush("foo", "1", "2", "3", "4", "5")
1480
+ result = [b"foo", [b"1", b"2"]]
1481
+ assert unstable_r.lmpop("2", "bar", "foo", "LEFT", count=2) == result
1482
+ with pytest.raises(redis.ResponseError):
1483
+ unstable_r.lmpop("2", "bar", "foo", count=2)
1484
+ unstable_r.rpush("bar", "a", "b", "c", "d")
1485
+ assert unstable_r.lmpop("2", ["bar", "foo"], "RIGHT") == [b"bar", [b"d"]]
1486
1487
def test_lindex(self, r):
1488
r.rpush("a", "1", "2", "3")
1489
assert r.lindex("a", "0") == b"1"
0 commit comments