Redis Learning Note – 05 Command in Redis (List)
RPUSH key value [value …]
Append one or multiple values at the tail of the list stored at key.
LPUSH key value [value …]
Prepend one or multiple values at the tail of the list stored at key.
LRANGE key start stop
Get a range of elements from a list. The offsets start and stop are zero-based indexes, with 0 being the first element of the list (the head of the list), 1 being the next element and so on, the rightmost item is included.
Remove and get the last element in a list.
BLPOP key [key …] timeout
It is the blocking version of LPOP because it blocks the connection when there are no elements to pop from any of the given lists.
BRPOP key [key …] timeout
It is the blocking version of RPOP.
If none of the specified keys exist, BLPOP blocks the connection until another client performs an LPUSH or RPUSH operation against one of the keys.
Once new data is present on one of the lists, the client returns with the name of the key unblocking it and the popped value.
When BLPOP causes a client to block and a non-zero timeout is specified, the client will unblock returning a nil multi-bulk value when the specified timeout has expired without a push operation against at least one of the specified keys.
The timeout argument is interpreted as an integer value specifying the maximum number of seconds to block. A timeout of zero can be used to block indefinitely.
RPOPLPUSH source destination
Atomically returns and removes the last element (tail) of the list stored at source, and pushes the element at the first element (head) of the list stored at destination.
BRPOPLPUSH source destination timeout
BRPOPLPUSH is the blocking variant of RPOPLPUSH. When source contains elements, this command behaves exactly like RPOPLPUSH. When source is empty, Redis will block the connection until another client pushes to it or until timeout is reached.