about zrank command in redis -
zrank returns rank of member in sorted set, with scores ordered low high. zrevrank returns rank scores ordered high low. when given member not exist in sorted set, special value 'nil' returned. returned rank (or index) of member 0-based both commands.
what 'with scores ordered low high. zrevrank returns rank scores ordered high low' meaning? in mind, zrank member's score. why pharse said orderd low high?
the important thing here zrank returns zero-based index of member, not it's score @ all. thus, "scores ordered low high" or "scores ordered high low" provide reference "direction" sorted set being read.
consider this:
redis> zadd foo 0 (integer) 1 redis> zadd foo 1 b (integer) 1 redis> zadd foo 2 c (integer) 1 redis> zrank foo c (integer) 2 redis> zrevrank foo c (integer) 0
note rank of c 2 when being read "scores low high" it's revrank 0 when being read "scores high low"
Comments
Post a Comment