Redis list

Redis list is simply a list of strings, sort insertion order. Redis can add elements in the list at the head or tail of the list.

The maximum length of the list is 2 ^ 32 - 1 elements (i.e. 4,294,967,295, each list can store more than four billion elements).

Examples

127.0.0.1:6379 Redis> LPUSH mylist "Redis"
(Integer). 1
Redis 127.0.0.1:6379> LPUSH mylist "MongoDB"
(Integer) 2
Redis 127.0.0.1:6379> LPUSH mylist "MySQL"
(Integer). 3
Redis 127.0 .0.1: 6379> 10 LRANGE mylist 0
. 1) "MySQL"
2) "MongoDB"
. 3) "Redis"
Shell
in the above example, the three values of the command list LPUSH Redis inserted entitled "mylist" in.

Redis list of commands

The following table lists some of the basic commands associated with the list.

No. Command Description
1 BLPOP key1 [key2] timeout deleted and obtains a first element of the list, or blocked, until a usable element
2 BRPOP key1 [key2] timeout deleted and obtain the last element in the list, or blocked until there is available an element
3 BRPOPLPUSH source destination timeout value from the list pop, push and return it to another list; or block until an available
4 LINDEX key index acquired by its index element from the list
5 lINSERT key BEFORE / AFTER pivot element value is inserted before or after another element in the list
6 LLEN key acquired length of the list
7 LPOP key remove and acquires a first element in the list
8 LPUSH key value1 [value2] to add one or more values to the list
9 LPUSHX key value only if there is a list, add it to the list of values
10 LRANGE key start stop access to a range of elements from a list
11 LREM key count value remove elements from the list
12 LSET key index value is set by the elements in the list of index values
13 LTRIM specified range of key trimmed the list of STOP Start
14 RPOP delete key and get the The last element of the table
15 RPOPLPUSH source destination removes the last item in the list, append it to another list and return
16 RPUSH key value1 [value2] one or more additional values to the list
17 RPUSHX key value only when the present value of the additional list to list

Released nine original articles · won praise 7 · views 10000 +

Guess you like

Origin blog.csdn.net/J_Jorey/article/details/77141823