ZRANK

Since 1.1.0Sorted sets

Syntax

ZRANK key member [WITHSCORE]
  • Flags: fast, readonly
  • ACL categories: @fast, @read, @sortedset
  • Arity: -3

Returns the rank of member in the sorted set at key: its position from the lowest score, starting at 0. With WITHSCORE, the score too.

Reply

  • The rank; with WITHSCORE, an array of the rank and the score.
  • nil if the member or the key does not exist.

Examples

> ZADD z 1 a 2 b 3 c
(integer) 3
> ZRANK z b
(integer) 1
> ZRANK z b WITHSCORE
1) (integer) 1
2) "2"