Skip to main content

ZRANK

Note

Official reference: ZRANK.

Read a member's ascending rank.

Syntax

ZRANK key member [WITHSCORE]

Ranks start at zero. WITHSCORE also returns the score (requires Redis 7.2+).

Results

ReturnRowsContent
ResultSet1SCORE field, DOUBLE type (when using WITHSCORE)
RANK field, LONG type
Caution

With WITHSCORE, a missing member can currently cause an error. Omit the option when only the rank is needed; a missing member then has a null RANK.

Example

ZADD demo:ranking 10 alice 20 bob
ZRANK demo:ranking bob WITHSCORE