ZRANK key member
Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has a rank of 0.
TIME COMPLEXITY: O(log(N))
RETURN VALUE:
If a member exists in the sorted set, Integer reply: the rank of the member.
If the member does not exist in the sorted set or key does not exist, Bulk reply: nil.
Syntax:
ZRANK key member
Example 1: When the member is present
redis:6379> ZADD mykey 1 A 2 B 3 C 4 D 5 E(integer) 5redis:6379> ZRANK mykey A(integer) 0redis:6379> ZRANK mykey B(integer) 1
Example 2: When the member or key is not present
redis:6379> ZADD mykey 1 A 2 B 3 C 4 D 5 E(integer) 5redis:6379> ZRANK mykey AA(nil)
Output
nil
No comments:
Post a Comment