lists_intro
LISTS Introduction
Apply for Redis Developer Course
|
Redis Regular Inspection / Technical Support
|
Redis Enterprise Server
|
|---|
Introduction
In Lists, a key and values have a one-to-many relationship.
Values are stored in insertion order.
Lists are mainly used as a Queue and a Stack.
A Queue is used to process incoming data in order.
A Stack is mainly used to go back, like a web browser Back button.
Values are stored in insertion order.
Lists are mainly used as a Queue and a Stack.
A Queue is used to process incoming data in order.
A Stack is mainly used to go back, like a web browser Back button.
Creating and deleting a key (list)
When a value is stored, the key (list) is created. If the key has no values, the key is deleted.
In other words, no extra work is needed to create or delete a key (list).
In other words, no extra work is needed to create or delete a key (list).
Command summary
- SET (PUSH): LPUSH, RPUSH, LPUSHX, RPUSHX, LSET, LINSERT, RPOPLPUSH
- GET: LRANGE, LINDEX, LLEN
- POP: LPOP, RPOP, BLPOP, BRPOP
- REM: LREM, LTRIM
- BLOCK: BLPOP, BRPOP, BRPOPLPUSH
| Commands | Version | Syntax | Description |
|---|---|---|---|
| LPUSH | 1.0.0 | key value [value ...] | Push values onto the left (head) of the list |
| RPOP | 1.0.0 | key | Pop a value from the right of the list and remove it from the list |
| LPOP | 1.0.0 | key | Pop a value from the left of the list and remove it from the list |
| RPUSH | 1.0.0 | key value [value ...] | Push values onto the right (tail) of the list |
| LRANGE | 1.0.0 | key start stop | Get a range of the list by index |
| LLEN | 1.0.0 | key | Get the total number of elements in the list |
| LINDEX | 1.0.0 | key index | Get the value at a given index |
| LSET | 1.0.0 | key index value | Change the value at a given index |
| LREM | 1.0.0 | key count value | Remove elements matching a value |
| LTRIM | 1.0.0 | key start stop | Trim the list to the specified index range |
| RPOPLPUSH | 1.2.0 | key src_key dest_key | RPOP + LPUSH |
| BLPOP | 2.0.0 | key [key ...] timeout | If the list is empty, wait up to the timeout and then run LPOP when a value arrives |
| BRPOP | 2.0.0 | key [key ...] timeout | If the list is empty, wait up to the timeout and then run RPOP when a value arrives |
| BRPOPLPUSH | 2.2.0 | src_key dest_key timeout | If the list is empty, wait up to the timeout and then run RPOPLPUSH when a value arrives |
| LINSERT | 2.2.0 | key BEFORE|AFTER pivot value | Insert a new value before or after a pivot |
| LPUSHX | 2.2.0 | key value | Run LPUSH only if the list already exists |
| RPUSHX | 2.2.0 | key value | Run RPUSH only if the list already exists |
| LPOS | 6.0.6 | key element | Get the index of a value |
| LMOVE | 6.2.0 | source destination | Move an element between lists |
| BLMOVE | 6.2.0 | source destination | Move an element between lists - blocking |
| LLS | Ent 6.0.0 | key pattern | Get values by a pattern |
| LRM | Ent 6.0.0 | key pattern | Delete values by a pattern |
Total : 22
Lists command explanation
Redis Internal : LIST internal data structure
-
Zip list (ZIPLIST): a memory-efficient data structure
- A zip list is a data structure shared by LIST, SORTED SET, and HASH,
- Learn about the data structure and main operations.
- Then see how it is used in LIST.
-
Main data structure of a list: Linked List
Learn about the linked list data structure and main operations. -
Quick List
Before version 3.2, lists with 512 or fewer entries were stored in a zip list, and from 513 entries they were stored in a linked list.
From Redis version 3.2, Quick List became the single internal data type for LIST.
Let's see what changed.
PDF manual
| << GETSET | LISTS Introduction | LPUSH >> |
|---|
Email
답글이 올라오면 이메일로 알려드리겠습니다.
