Lists #
18 commands. Lists are stored as an indexed sequence; two of these commands rebuild the whole list.
| Cmd | RW | Syntax | Returns | Example → reply |
|---|---|---|---|---|
LPUSH | W | LPUSH KEY VALUE [VALUE ...] | integer new length | LPUSH q a b → 2 |
RPUSH | W | RPUSH KEY VALUE [VALUE ...] | integer new length | RPUSH q c → 3 |
LPOP | W | LPOP KEY | bulk head element, null if empty | LPOP q → b |
RPOP | W | RPOP KEY | bulk tail element, null if empty | RPOP q → c |
LLEN | R | LLEN KEY | integer element count | LLEN q → 1 |
LINDEX | R | LINDEX KEY index | bulk, null if out of range | LINDEX q 0 → a |
LRANGE | R | LRANGE KEY start stop | array (inclusive, negative offsets from the end) | LRANGE q 0 -1 → [a] |
LSET | W | LSET KEY index VALUE | +OK | LSET q 0 z → OK |
LTRIM | W | LTRIM KEY start stop | +OK | LTRIM q 0 0 → OK |
RPOPLPUSH | W | RPOPLPUSH source destination | bulk moved element, null if source empty | RPOPLPUSH q backup → z |
LINSERT | W | LINSERT KEY BEFORE|AFTER pivot VALUE | integer new length; 0 pivot absent; -1 key absent | LINSERT q BEFORE z y → 2 |
LREM | W | LREM KEY count VALUE | integer elements removed | LREM q 0 z → 1 |
LKEYEXISTS | R | LKEYEXISTS KEY | integer 0/1 — does the list exist | LKEYEXISTS q → 1 |
LCLEAR | W | LCLEAR KEY | integer elements removed | LCLEAR q → 1 |
LMCLEAR | W | LMCLEAR KEY [KEY ...] | integer lists removed | LMCLEAR a b → 2 |
LEXPIRE | W | LEXPIRE KEY seconds | integer 1/0 | LEXPIRE q 600 → 1 |
LEXPIREAT | W | LEXPIREAT KEY unixTime | integer 1/0 | LEXPIREAT q 1767225600 → 1 |
LTTL | R | LTTL KEY | integer seconds left, -1 none | LTTL q → 599 |
Notes #
LPUSH q a bproduces[b, a]— each element is pushed to the head in turn, as in Redis.LREM KEY count VALUE:count > 0removes from the head,count < 0from the tail,count = 0every occurrence.LINSERTandLREMare O(n) and are not transactional. The storage layer has no primitive for them, so the handler reads the list, clears it, and rewrites it (restoring the TTL). It happens inside one Raft apply, so no other client observes a partial list, but a backend failure mid-rebuild leaves the list truncated. Do not use them on long lists in a hot path — preferLTRIMor bounded queues.- There is no
LPERSIST: the handler is not registered.LCLEAR/LMCLEARdelete the list and its TTL. - No blocking commands.
BLPOP/BRPOPare deliberately not registered: a blocking read inside the Raft apply loop either stalls the log or consumes the queue without a rollback path. LRANGEwithstart > stopanswers an empty array; negative indexes count from the tail.