# Lists — Redis

Source: https://www.geekswithgeeks.com/en/redis/redis-lists

> Ordered collections — great for queues and recent-activity feeds.

## Push & read a list

`LPUSH` adds to the left (head), `RPUSH` to the right (tail). `LRANGE` reads a slice — use `0 -1` for the whole list.

```bash
RPUSH recent:logins "ada" "bo" "chi"
LPUSH recent:logins "dee"
LRANGE recent:logins 0 -1
```

Output:

```
1) "dee"
2) "ada"
3) "bo"
4) "chi"
```

## Lists as a queue

`RPUSH` to enqueue, `LPOP` to dequeue — a simple FIFO job queue with no extra tools.

```bash
RPUSH jobs:emails "send:welcome:42"
LPOP jobs:emails
```

Output:

```
(integer) 1
"send:welcome:42"
```

## Trim old entries

`LTRIM key 0 99` keeps only the newest 100 items — perfect for capping an activity feed's size.
