常用命令
127.0.0.1:6379> zadd topn 100 java 300 c++ 400 mysql 500 php ##添加数据
(integer) 4
127.0.0.1:6379> zrange topn 0 -1##按照顺序取出全部数据
1) "java"
2) "c++"
3) "mysql"
4) "php"
-------------------------------------------------------------------
127.0.0.1:6379> zrange topn 0 -1 withscores##按照顺序取出全部数据和scores
1) "java"
2) "100"
3) "c++"
4) "300"
5) "mysql"
6) "400"
7) "php"
8) "500"
127.0.0.1:6379>
--------------------------------------------------------------------
127.0.0.1:6379> zrangebyscore topn 300 500##按照score的范围取值
1) "c++"
2) "mysql"
3) "php"
127.0.0.1:6379>
127.0.0.1:6379> zrangebyscore topn 300 500 withscores##按照score的范围取值和scores
1) "c++"
2) "300"
3) "mysql"
4) "400"
5) "php"
6) "500"
127.0.0.1:6379>
-------------------------------------------------------------------------------------
127.0.0.1:6379> zrevrangebyscore topn 500 300 withscores##顺序 反过来
1) "php"
2) "500"
3) "mysql"
4) "400"
5) "c++"
6) "300"
127.0.0.1:6379>
---------------------------------------------------------------------------------------------
127.0.0.1:6379> zincrby topn 50 java##增加某个scorpe
"150"
127.0.0.1:6379> zrange topn 0 -1 withscores
1) "java"
2) "150"
3) "c++"
4) "300"
5) "mysql"
6) "400"
7) "php"
8) "500"
127.0.0.1:6379>
-----------------------------------------------------------------------------------
127.0.0.1:6379> zrange topn 0 -1 withscores##删除某个member
1) "java"
2) "150"
3) "c++"
4) "300"
5) "mysql"
6) "400"
127.0.0.1:6379>
-----------------------------------------------------------------
127.0.0.1:6379> zcount topn 0 500##统计score在某个范围内的元素数量
(integer) 3
127.0.0.1:6379>
----------------------------------------------------
127.0.0.1:6379> zrank topn mysql##返回某个member的排名
(integer) 2
127.0.0.1:6379>
-----------------------------------------------------