Redis Commands - Sorted Sets - zrevrank

 

original

http://redis.io/commands/zrevrank

 

Introduction

Determine the index of a member in a sorted set, with scores ordered from high to low.

 

Determines the index of the member in the sorted set, in order of highest to lowest score.

 

grammar

ZREVRANK key member

 

Version

Available since 2.0.0.

 

Available since version 2.0.0.

 

time complexity

Time complexity: O(log(N))

 

describe

Returns the rank of member in the sorted set stored at 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.

 

Returns the order of the members in the sorted set, from high to low score. The order (or index) is 0-based, meaning that the order of the highest scoring member is 0.

 

Use ZRANK to get the rank of an element with the scores ordered from low to high.

 

Use ZRANK to get the order of elements, sorted by score from low to high.

 

return value

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

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

 

1) If the member exists in the sorted set, return the order of the members.
2) If the member does not exist in the sorted set, or the key does not exist, return nil.

 

example

redis>  ZADD myzset 1 "one"
(integer) 1
redis>  ZADD myzset 2 "two"
(integer) 1
redis>  ZADD myzset 3 "three"
(integer) 1
redis>  ZREVRANK myzset "one"
(integer) 2
redis>  ZREVRANK myzset "four"
(nil)
redis>

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327034090&siteId=291194637