Redis (6): SortSet common commands of data structure

SortSet 

key ->{ key , sorce}

1.ZADD

127.0.0.1:6379> ZADD scoreset 10 java 9 python 8 go 22 js
(integer) 4

2. The number of ZCOUNT score intervals

127.0.0.1:6379> zcount scoreset 0 10
(integer) 3

3.ZSCORE get score

127.0.0.1:6379> ZSCORE scoreset java
"10"

4. ZINCRBY increase
5. ZCARD total number
6. ZRANGE get set 

127.0.0.1:6379> ZRANGE scoreset 0 -1
1) "go"
2) "python"
3) "java"
4) "js" 


7. ZREVRANGE in descending order by score

127.0.0.1:6379> ZREVRANGE scoreset 0 -1
1) "js"
2) "java"
3) "python"
4) "go"


8.ZRANGEBYSCORE only get the score interval elements without sorting

5<=score<=10
127.0.0.1:6379> ZRANGEBYSCORE scoreset 5 10
1) "go"
2) "python"
3) "java"
5<=score<10
127.0.0.1:6379> ZRANGEBYSCORE scoreset 5 (10
1) "go"
2) "python"

9.ZREVRANGEBYSCORE get the score interval elements and descending order

127.0.0.1:6379> ZREVRANGEBYSCORE scoreset 10 5
1) "java"
2) "python"
3) "go"

10. ZRANK ranks the largest first

127.0.0.1:6379> ZRANK scoreset js
(integer) 3

11.ZREVRANK 0 means first place

127.0.0.1:6379> ZRevrank scoreset js
(integer) 0

 

Guess you like

Origin blog.csdn.net/qq_22420441/article/details/87536400