总共五种数据类型:

 

1、Strings - 字符串

127.0.0.1:6379> set name "zhaoja"
OK
127.0.0.1:6379> get name
"zhaoja"

 

2、Hashes - 哈希值

 

 

 

3、Lists - 列表
Redis的列表是简单的字符串列表,排序插入顺序。可以添加元素到Redis列表的头部或尾部

127.0.0.1:6379> lpush nlist zhaoja
(integer) 1
127.0.0.1:6379> lpush nlist zhaoja2
(integer) 2
127.0.0.1:6379> lrange nlist 0 10
1) "zhaoja2"
2) "zhaoja"

  

 

 

4、Sets - 集合
Redis集合是字符串的无序集合

127.0.0.1:6379> sadd nalist zhaoja1
(integer) 1
127.0.0.1:6379> sadd nalist zhaoja2
(integer) 1
127.0.0.1:6379> sadd nalist zhaoja3
(integer) 1
127.0.0.1:6379> smembers nalist
1) "zhaoja3"
2) "zhaoja2"
3) "zhaoja1"

  

 

5、集合排序
Redis的集合排序类似于Redis集合,字符串不重复的集合

127.0.0.1:6379> zadd namlist 0 zhaoja1
(integer) 1
127.0.0.1:6379> zadd namlist 0 zhaoja2
(integer) 1
127.0.0.1:6379> zadd namlist 0 zhaoja3
(integer) 1
127.0.0.1:6379> zadd namlist 0 zhaoja4
(integer) 1
127.0.0.1:6379> zrangebyscore namlist 0 1000
1) "zhaoja1"
2) "zhaoja2"
3) "zhaoja3"
4) "zhaoja4"

  

 

posted on 2015-05-04 17:18  充实自己  阅读(213)  评论(0编辑  收藏  举报