标签:
DEl job command request#删除元素
0
LPUSH command "update system"#添加元素
1
LPUSH request "visit page"
1
BLPOP job command request 0#弹出存在元素的第一个非空列表
command#表名
update system#第一个元素
redis> EXISTS job # 确保两个 key 都不存在
(integer) 0
redis> EXISTS command
(integer) 0
redis> BLPOP job command 300 # 因为key一开始不存在,所以操作会被阻塞,直到另一客户端对 job 或者 command 列表进行 PUSH 操作。
1) "job" # 这里被 push 的是 job
2) "do my home work" # 被弹出的值
(26.26s) # 等待的秒数
redis> BLPOP job command 5 # 等待超时的情况
(nil)
(5.66s) # 等待的秒数
RPUSH job programming
1
MULTI
OK
BLPOP job 10
QUEUED
EXEC#执行非空列表,立即返回
job
programming
LLEN job
0
MULTI
OK
BLPOP job 5
QUEUED
EXEC#执行空列表,返回nil
(nil)
BRPOPLPUSH msg reciver 10#空列表
(nil)
(10.33s)
LPUSH msg "hello"
1
BRPOPLPUSH msg reciver 10#非空 列表
hello
LLEN reciver
1
LPUSH mylist "World"
1
LPUSH mylist "HELLO"
2
LINDEX mylist 0
HELLO
LINDEX mylist -1
World
LINSERT mylist BEFORE "World" "Three"
3
LRANGE mylist 0 -1
HELLO
Three
World
LLEN job
1
LPUSH job "sda"
2
LLEN job
2
LLEN course
0
RPUSH course 01
1
RPUSH course 02
2
LPOP course
01
LLEN course
1
LPUSH languages python
1
LPUSH languages python
2
LRANGE languages 0 -1
python
python
LPUSH languages a b c
5
LRANGE languages 0 -1
c
b
a
python
python
LLEN greet
0
LPUSHX greet "hello"
0
LPUSH greet "hello"
1
LPUSHX greet "hello"
2
LRANGE greet 0 -1
hello
hello
RPUSH language lisp
1
RPUSH language java
2
LRANGE language 0 0
lisp
LRANGE language 0 1
lisp
java
LPUSH greet "morning"
1
LPUSH greet "hello"
2
LPUSH greet "morning"
3
LPUSH greet "hello"
4
LPUSH greet "morning"
5
LRANGE greet 0 4
morning
hello
morning
hello
morning
LREM greet 2 morning
2
LLEN morning
0
LLEN greet
3
LREM greet -1 morning
1
LLEN greet
2
LRANGE greet 0 -1
hello
hello
EXISTS list
0
LSET list 0 item
ERR no such key
LPUSH job "cook"
1
LRANGE job 0 0
cook
LSET job 0 "play game"
OK
LRANGE job 0 -1
play game
LPUSH alpha a b c d e f g
7
LTRIM alpha 1 -1
OK
LRANGE alpha 0 -1
f
e
d
c
b
a
LTRIM alpha 1 -1
OK
LRANGE alpha 0 -1
e
d
c
b
a
LRANGE alpha 0 -1
e
d
c
b
a
RPOP alpha
a
LRANGE alpha 0 -1
e
d
c
b
LRANGE alpha 0 -1
e
d
c
b
RPOPLPUSH alpha reciver
b
LRANGE alpha 0 -1
e
d
c
LRANGE reciver 0 -1
b
RPOPLPUSH alpha reciver
c
LRANGE alpha 0 -1
e
d
LRANGE reciver 0 -1
c
b
RPUSH language c
1
LRANGE language 0 -1
c
RPUSH language a b c
4
LRANGE language 0 -1
c
a
b
c
LLEN greet
0
RPUSHX greet "hello"
0
RPUSH greet a
1
RPUSHX greet "hello"
2
标签:
原文地址:http://blog.csdn.net/mergades/article/details/46491303