Redis list operation

list operation
lpush: insert
lpush from the left list 1 2 3 4 5 6 7

rpush: insert
rpush list2 1 2 3 4 5 6 7 from the right

View data
lrange list 0 -1

Popup data pops up
from the left: lpop list

Pop from the right: rpop list2

get length
llen list

Access
lindex list 2 by index


Popup blpop list with timeout 10

set a value to an index
lset list 2 0
lrange list 0 -1

Intercept a segment
ltrim list 1 2
lrange list 0 -1


append
rpush a 10

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325074470&siteId=291194637