一 LINSERT
1 介绍
在列表中某个存在值(pivot)前或后插入元素
LINSERT key BEFORE|AFTER pivot value
key和pivot不存在,不进行任何操作
2 举例
127.0.0.1:6379> RPUSH lst Coljure C Lua
(integer) 3
127.0.0.1:6379> LINSERT lst after C Python
(integer) 4
127.0.0.1:6379> LINSERT lst before C Ruby
(integer) 5
127.0.0.1:6379> LRANGE lst 0 -1
1) "Coljure"
2) "Ruby"
3) "C"
4) "Python"
5) "Lua"
127.0.0.1:6379> LINSERT lst before temp c++
(integer) -1
127.0.0.1:6379> LRANGE lst 0 -1
1) "Coljure"
2) "Ruby"
3) "C"
4) "Python"
5) "Lua"
3 图例

二 阻塞
1 介绍
如果弹出的列表不存在或者为空,就会阻塞
超时时间设置为0,就会永久阻塞,直到有数据可以弹出
如果多个客户端阻塞在同一个列表中,使用First In First Service原则,先到先服务
2 命令
左右或者头尾阻塞弹出元素
BLPOP key [key ...] timeout
BRPOP key [key ...] timeout
从一个列表尾部阻塞弹出元素压入到另一个列表头部
BRPOPLPUSH source destination timeout