![](https://www.dazhuanlan.com/webchat.jpg)
Redis是一种key-value的基于内存数据结构存储系统,它可以用作数据库
、缓存
和消息中间件库
。Redis有5种数据结构strings
,lists
,sets
,sorted sets
,hashes
。
strings
1 2 3 4 5 6
|
PUT key value GET key DEL key EXPIRE key time TTL key
|
lists
1 2 3 4 5 6
|
LPUSH key value RPUSH key value LPOP RPOP LRANGE start end
|
sets
1 2 3 4
|
SADD key value SREM key value SISMEMBER key value SMEMBERS key
|
sorted sets
1 2 3 4 5
|
ZADD hackers 2 Bob ZADD hackers 1 Alan ZADD hackers 1 Zbra ZRANGE hackers 0 -1
|
hashes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
HSET user:1000 name Rick HSET user:1000 age 38 HGETALL user:1000 => 1) "name" 2) "Rick" 3) "age" 4) "38" 5) "email" HGET user:1000 name => Rick HINCRBY user:1000 age 1=> integer 39 HINCRBY user:1000 age 11=> integer 50 HDEL user:1000 age HINCRBY user:1000 age 11=> integer 11
|
近期评论