English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Redis Sorted Sets (sorted set)
The Redis Zrevrank command returns the ranking of members in the sorted set. The members in the sorted set are sorted by score value in descending order (from large to small).
The ranking starts from 0, which means that the member with the highest score value has a ranking of 0.
Using the ZRANK command, you can obtain the ranking of members sorted by score value in ascending order (from small to large).
The basic syntax of the redis Zrevrank command is as follows:
redis 127.0.0.1:6379> ZREVRANK key member
>= 2.2.0
If the member is a member of the sorted set key, return the member's rank. If the member is not a member of the sorted set key, return nil.
redis 127.0.0.1:6379> ZRANGE salary 0 -1 WITHSCORES # Test data 1)"jack" 2)"2000" 3)"peter" 4)"3500" 5)"tom" 6)"5000" redis 127.0.0.1:6379> ZREVRANK salary peter # peter's salary is the second (integer) 1 redis 127.0.0.1:6379> ZREVRANK salary tom # tom's salary is the highest (integer) 0