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.

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).

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

Lists command list

CommandsVersionSyntaxDescription
LPUSH1.0.0key value [value ...]Push values onto the left (head) of the list
RPOP1.0.0keyPop a value from the right of the list and remove it from the list
LPOP1.0.0keyPop a value from the left of the list and remove it from the list
RPUSH1.0.0key value [value ...]Push values onto the right (tail) of the list
LRANGE1.0.0key start stopGet a range of the list by index
LLEN1.0.0keyGet the total number of elements in the list
LINDEX1.0.0key indexGet the value at a given index
LSET1.0.0key index valueChange the value at a given index
LREM1.0.0key count valueRemove elements matching a value
LTRIM1.0.0key start stopTrim the list to the specified index range
RPOPLPUSH1.2.0key src_key dest_keyRPOP + LPUSH
BLPOP2.0.0key [key ...] timeoutIf the list is empty, wait up to the timeout and then run LPOP when a value arrives
BRPOP2.0.0key [key ...] timeoutIf the list is empty, wait up to the timeout and then run RPOP when a value arrives
BRPOPLPUSH2.2.0src_key dest_key timeoutIf the list is empty, wait up to the timeout and then run RPOPLPUSH when a value arrives
LINSERT2.2.0key BEFORE|AFTER pivot valueInsert a new value before or after a pivot
LPUSHX2.2.0key valueRun LPUSH only if the list already exists
RPUSHX2.2.0key valueRun RPUSH only if the list already exists
LPOS6.0.6key elementGet the index of a value
LMOVE6.2.0source destinationMove an element between lists
BLMOVE6.2.0source destinationMove an element between lists - blocking
LLS Ent 6.0.0key patternGet values by a pattern
LRM Ent 6.0.0key patternDelete 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 답글이 올라오면 이메일로 알려드리겠습니다.