Lux Docs

Build on Lux without guessing.

Lux Cloud + OSS core

Product docs for the Lux runtime: tables, cache, vectors, realtime, time series, auth, HTTP, SDK, CLI, and self-hosting.

Lists

Lists are ordered sequences of strings, implemented as linked lists. They support push/pop from both ends in O(1) and are commonly used for queues, stacks, and activity feeds.

LPUSH / RPUSH / LPOP / RPOP

Push elements to the head or tail of a list, and pop elements from either end. Multiple elements can be pushed in a single call.

Syntax
LPUSH key element [element ...]
RPUSH key element [element ...]
LPOP key [count]
RPOP key [count]
Example
> RPUSH queue:jobs "job:1" "job:2" "job:3"
(integer) 3
> LPOP queue:jobs
"job:1"
> RPOP queue:jobs
"job:3"
> LPUSH stack:undo "action:5"
(integer) 1

LRANGE / LLEN / LINDEX

LRANGE returns elements in a range (0-based, inclusive). Use -1 for the last element. LLEN returns the list length. LINDEX returns the element at a given index.

Example
> RPUSH feed:user1 "post:a" "post:b" "post:c" "post:d"
(integer) 4
> LRANGE feed:user1 0 -1
1) "post:a"
2) "post:b"
3) "post:c"
4) "post:d"
> LRANGE feed:user1 0 1
1) "post:a"
2) "post:b"
> LLEN feed:user1
(integer) 4
> LINDEX feed:user1 2
"post:c"

LSET / LINSERT / LREM / LTRIM

Modify lists in place. LSET updates an element by index. LINSERT adds before or after a pivot. LREM removes occurrences. LTRIM keeps only a range and discards the rest.

Example
> LSET feed:user1 0 "post:updated"
OK
> LINSERT feed:user1 BEFORE "post:c" "post:new"
(integer) 5
> LREM feed:user1 1 "post:d"
(integer) 1
> LTRIM feed:user1 0 99
OK

LMOVE / RPOPLPUSH

Atomically move an element from one list to another. LMOVE is the generalized form; RPOPLPUSH pops from the tail of the source and pushes to the head of the destination.

Syntax
LMOVE source destination LEFT|RIGHT LEFT|RIGHT
Example
> RPUSH queue:pending "task:1" "task:2"
(integer) 2
> LMOVE queue:pending queue:processing LEFT RIGHT
"task:1"
> RPOPLPUSH queue:pending queue:processing
"task:2"

BLPOP / BRPOP / BLMOVE

Blocking variants that wait for elements when the list is empty. The timeout is in seconds (0 means block indefinitely). These are the foundation for reliable queue patterns.

Syntax
BLPOP key [key ...] timeout
BRPOP key [key ...] timeout
BLMOVE source destination LEFT|RIGHT LEFT|RIGHT timeout
Example
> BLPOP queue:jobs 30
1) "queue:jobs"
2) "job:42"

Command Reference

CommandDescription
LPUSHPush elements to the head of a list
RPUSHPush elements to the tail of a list
LPOPRemove and return element from the head
RPOPRemove and return element from the tail
LLENGet the length of a list
LRANGEGet elements in a range
LINDEXGet element by index
LSETSet element at an index
LINSERTInsert before or after a pivot element
LREMRemove elements by value
LTRIMTrim list to a specified range
LPOSFind the position of an element
LMOVEAtomically move element between lists
RPOPLPUSHPop from tail, push to head of another list
LPUSHXPush to head only if the list exists
RPUSHXPush to tail only if the list exists
BLPOPBlocking pop from the head
BRPOPBlocking pop from the tail
BLMOVEBlocking move between lists