If I have 5 members with scores as follows
a - 1
b - 2
c - 3
d - 3
e - 5
ZRANK of c returns 2, ZRANK of d returns 3
Is there a way
You can achieve the goal with two Sorted Set: one for member to score mapping, and one for score to rank mapping.
Add
ZADD mem_2_score 1 a 2 b 3 c 3 d 5 e
ZADD score_2_rank 1 1 2 2 3 3 5 5
Search
ZSCORE mem_2_score c
, this should return the score, i.e. 3
.ZRANK score_2_rank 3
, this should return the dense ranking, i.e. 2
.In order to run it atomically, wrap the Add, and Search operations into 2 Lua scripts.