Re: sorted set get rank

7 views
Skip to first unread message
Message has been deleted

Josiah Carlson

unread,
May 31, 2011, 11:45:08 AM5/31/11
to redi...@googlegroups.com
On Tue, May 31, 2011 at 7:47 AM, Karl Seguin <karls...@gmail.com> wrote:
> Hi,
> I'm in need of getting a rank from a sorted set on arbitrary scores
> (unsaved). Currently the API only allows for ranks from a saved member. The
> use case that I'm specifically interested in is to return leaderboard ranks
> to users when the score isn't their best score (and thus isn't saved). We
> only track a user's best score, but we like to show them what rank a score
> was - even if its worse than their best rank.
> I'm curious if such a patch might be welcomed?
> I haven't programmed in C, but I really need this feature and I'm happy to
> maintain my own patched fork and run with it. I feel like I have an ok
> implementation for skiplists, but I'm struggling with the ziplist
> implementation. I'm thinking I'm going to have to iterate though and call
> something like zzlGetScore on each entry to find the rank. Any thoughts
> suggestion?
> here's what I have so far if anyone is interested:
> https://github.com/karlseguin/redis/commit/e2a5ac71406178d2e515a1234d21d2c6451f53e8

Why not:

MULTI
ZADD topscores <score> <tempkey>
ZRANK topscores <tempkey>
ZREM topscores <tempkey>
EXEC

No need to patch Redis :)

- Josiah

Reply all
Reply to author
Forward
0 new messages