BRPOPLPUSH
Since 1.1.0Lists
Syntax
BRPOPLPUSH source destination timeoutPops the last element of source and pushes it onto the front of destination, waiting for an element if source is empty. It is the blocking form of RPOPLPUSH, and the same as BLMOVE source destination RIGHT LEFT timeout. Use BLMOVE in new code; BRPOPLPUSH remains for older clients.
timeout: seconds to wait, with decimals allowed.0waits for ever.
If source is empty, the connection waits until another client pushes to it, or until the timeout passes. destination is created if missing. source and destination may be the same list, which moves its last element to the front. If destination holds another type, the command fails with WRONGTYPE and nothing moves. Inside a MULTI transaction it does not wait. See BLMOVE for how to build a reliable queue with it.
Reply
- The element moved.
nilif the timeout passed.
Errors
ERR timeout is negative.ERR timeout is not a float or out of rangeif the timeout is not a number.WRONGTYPE Operation against a key holding the wrong kind of valueifsource, ordestinationwhen there is an element to move, is not a list.
Examples
> RPUSH jobs j1 j2
(integer) 2
> BRPOPLPUSH jobs work 1
"j2"
> LRANGE work 0 -1
1) "j2"
> RPUSH r a b c
(integer) 3
> BRPOPLPUSH r r 0
"c"
> LRANGE r 0 -1
1) "c"
2) "a"
3) "b"
> BRPOPLPUSH empty work 0.5
(nil)