Upstash Documentation

LMOVE

Move element between lists.
2 min read

Use LMOVE to atomically take an element from one end of a list and push it onto one end of another list, returning the element.

The two directions are chosen independently: LEFT RIGHT takes from the head of the source and appends to the tail of the destination, which preserves order when transferring between queues, while LEFT LEFT behaves like moving between stacks. If the source is empty nothing happens and the reply is null. Source and destination may be the same key, in which case the list is rotated.

Because the element is never outside a list, LMOVE is the building block for reliable queues: a worker moves an item into a processing list, does the work, and removes it from there, so a crash leaves the item recoverable instead of lost. It replaces the deprecated RPOPLPUSH, and BLMOVE is the blocking form.

Syntax#

Arguments#

ArgumentRequiredRepeatableDescription
<source>YesNoRedis key used as source.
<destination>YesNoRedis key used as destination.
(LEFT | RIGHT)YesNoWhich end of the source list the element is taken from: LEFT (head) or RIGHT (tail).
(LEFT | RIGHT)YesNoWhich end of the destination list the element is pushed onto: LEFT (head) or RIGHT (tail).

Response#

The reply reports the result of the operation. Error replies have the same shape in RESP2 and RESP3 and are surfaced as exceptions by the SDKs below.

ProtocolReply
RESP2Bulk string
RESP3Bulk string
Note

Client libraries often decode bulk strings, maps, sets, and numeric strings into language-native values. The table describes the Redis wire reply.

Examples#

TCP examples use the TLS REDIS_URL from the Upstash console. REST examples use UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN.

Redis CLI
@upstash/redis
upstash_redis
ioredis
node-redis
redis-py
go-redis
jedis
redis-rs