ZRANK by index

Apply for Redis Developer Course Redis Regular Inspection / Technical Support Redis Enterprise Server

Return the index (rank) of a member

Usage: zrank key member.
The return value is an index, the same concept used by lrange.
Ranks are assigned in score order starting from 0. If scores are equal, members are compared.

Example

Command>zrange city 0 -1 withscores
Result> 0) 50 -> New Delhi
1) 60 -> Seoul
2) 70 -> Beijing
3) 80 -> New York
Command>zrank city "Seoul"
Result>1
Command>zrank city "New York"
Result>3

View animation



Syntax

ZRANK key member

  • Available since version 2.0.0.
  • Time complexity is O(log(N)+M).
Related commands ZREVRANGE, LRANGE
Clients for Java Jedis, Lettuce, Redisson
Clients for C Hiredis

<< ZLEXCOUNT ZRANK ZREVRANK >>

Email 답글이 올라오면 이메일로 알려드리겠습니다.