Ordered by Insertion
A Redis list is an ordered collection of strings, implemented as a linked list so pushes and pops at either end are fast. You manipulate the ends with:
- LPUSH and RPUSH to add at the left or right.
- LPOP and RPOP to remove from the left or right.
- LRANGE to read a slice.
Queues and Stacks
Combining ends gives you classic structures:
- Queue with LPUSH to enter and RPOP to leave, so items are consumed in arrival order.
- Stack with LPUSH and LPOP, so the newest item comes out first.
This makes lists a popular job queue: producers LPUSH tasks, workers RPOP them.
Blocking Pops
Polling an empty queue wastes CPU. Redis offers BLPOP and BRPOP that block the worker until an item arrives or a timeout passes. The worker sleeps cheaply and wakes the instant a task is pushed.
Reliability Caveat
A plain RPOP removes the task before the worker finishes. If the worker crashes, the task is lost. LMOVE (or the older RPOPLPUSH) atomically moves the item to a processing list, so you can recover in flight work. For richer delivery guarantees, streams are often a better fit.
Key idea
Redis lists are double ended sequences that model queues and stacks, with blocking pops for efficient workers and LMOVE for safer task handoff.