Redis - Sorted Set Zrevrank Command



Redis ZREVRANK command returns the rank of the member in the sorted set stored at the key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0.

Return Value

  • If the member exists in the sorted set, Integer reply − the rank of member.

  • If the member does not exist in the sorted set or the key does not exist, Bulk string reply − nil.

Syntax

Following is the basic syntax of Redis ZREVRANK command.

redis 127.0.0.1:6379> ZREVRANK key member

Example

redis 127.0.0.1:6379> ZADD myzset 1 b 2 c 3 d 4 e 
(integer) 4 
redis 127.0.0.1:6379> ZREVRANK myzset "c" 
(integer) 3 
redis 127.0.0.1:6379> ZREVRANK myzset "y" 
(nil)
redis_sorted_sets.htm
Advertisements