Suggest an editImprove this articleRefine the answer for “What is List in Redis?”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)A List in Redis is an ordered collection of string values, implemented as a double-ended queue (a doubly linked list): elements are stored in insertion order, duplicate values are allowed, and elements can be added or removed from either end via `LPUSH`/`RPUSH` and `LPOP`/`RPOP`. **Key point:** it fits queues (FIFO), stacks (LIFO), action logs, and temporary buffers; the blocking versions `BLPOP`/`BRPOP` wait for an element to appear, which is handy for asynchronous queues.Shown above the full answer for quick recall.Answer (EN)ImageA **List** in Redis is an **ordered collection of string values**, implemented as a **double-ended queue (a doubly linked list)**. Every element is a Redis String, and insertion order is preserved. ### Main properties - **Elements are stored in the order they were added.** - Elements can be added and removed **from either end**, from the front or the back. - **Duplicate values are allowed** (it's not a Set). - It fits **queues, stacks, logs, action histories**, and temporary buffers. ### Example ```bash LPUSH tasks "send the report" RPUSH tasks "call with the client" LRANGE tasks 0 -1 ``` Result: ```javascript 1) "call with the client" 2) "send the report" ``` `LPUSH` adds to the front, `RPUSH` adds to the back. ### Main commands | Command | Description | |---|---| | `LPUSH key value [value ...]` | add element(s) to the **front** of the list | | `RPUSH key value [value ...]` | add element(s) to the **back** of the list | | `LPOP key` | remove and return an element **from the front** | | `RPOP key` | remove and return an element **from the back** | | `LRANGE key start stop` | get a range of elements | | `LLEN key` | get the list's length | | `LINDEX key index` | get an element by index | | `LREM key count value` | remove an element by value | | `LTRIM key start stop` | trim the list to a range | ### A queue example ```bash RPUSH queue "task1" RPUSH queue "task2" LPOP queue ``` Result: ```javascript "task1" ``` `"task2"` is left. This is how a **FIFO queue (first in, first out)** is implemented. ### A stack example ```bash LPUSH stack "item1" LPUSH stack "item2" LPOP stack ``` Result: ```javascript "item2" ``` This is how a **LIFO stack (last in, first out)** works. ### Additional capabilities - The `BLPOP` and `BRPOP` commands are **blocking versions**: they wait for an element to appear (handy for asynchronous queues). - `LPUSHX` and `RPUSHX` add an element **only if the list already exists**. - `LSET` lets you change an element by index. ### Internal structure Redis stores lists in two formats: 1. **Quicklist**, the main structure: a combination of a doubly linked list and a ziplist (a compact array). 2. **Ziplist (deprecated)**, used for very short lists. Quicklist picks the optimal storage method: if there are few elements, they're stored compactly in memory, as the list grows, Redis automatically "unpacks" it into a more efficient form. ### Uses - Task queues between services - Storing a feed of messages or actions - Implementing undo/redo - Temporary log buffersFor the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.