Ufraan's Notes Digital garden & personal knowledge base
Last modified: Jun 28, 2026Home / 02_cs / Databases / Redis / Redis Lists.Md

cs

A Redis list is an ordered collection of elements stored under a single key.

Elements maintain their insertion order and can be added or removed from either side of the list.

Lists are commonly used to implement:

Example list:

tasks → ["task1", "task2", "task3"]

lists in redis.png

Adding Elements

LPUSH

Adds an element to the left side of the list.

LPUSH tasks "task1"

RPUSH

Adds an element to the right side.

RPUSH tasks "task2"

After these operations:

tasks → ["task1", "task2"]

Removing Elements

LPOP

Removes the first element.

LPOP tasks

RPOP

Removes the last element.

RPOP tasks

Reading Elements

LRANGE

Retrieves elements within a range.

LRANGE tasks 0 -1

0 represents the first element.
-1 represents the last element.

List Length

LLEN tasks

Returns the number of elements in the list.

Queue Example

A simple job queue can be implemented using:

RPUSH jobs "send_email"  
RPUSH jobs "generate_report"

Workers then process jobs using:

LPOP jobs

This creates a FIFO queue (First In First Out).


Related: [[Redis]] [[Redis - Strings]] [[Redis - Sets]] [[Redis - Hashes]] [[Redis - Sorted sets]]