How would one implement a sorted list like Redis

Hi guys,

In the case of a leader scoreboard (score - PlayerID), 2 LLISTs? One ordered list (Score-PlayerID) and another (PlayerID-Score)? With a number of PlayerIDs key-maps. And a UDF iterating through the LLISTs to retrieve the individual PlayerID key-maps? This seems quite convoluted. Appreciate any help… =)

Hi,

Pl read this recent post which talks about finding “top 10” (which aligns with a leaderboard use case) using Aerospike Aggregations - http://www.aerospike.com/blog/top-10-aerospike-aggregations/

You will find that most of the work is done in UDFs (written in Lua) so the implementation described in the post is client-language agnostic for the most part.

I hope this helps you get started.

1 Like

On the related note. I am assuming you mean Redis Sorted Set.

Given that your sort key (score) and your lookup key (id) are different only way to solve this is to have two structure one for sorting and another one for lookup. This is precisly Sorted Set in Redis does internally as well it has sorted list of score and hash for unique id.

So you have to write UDF to deal with two llist.

Can you share some more detail. Is it only

player-id-score or is there some more associated data …

– R

1 Like

Hi Raj, how would you handle identical scores by different players? In which case, one of our LList will have 2 similar keys (scores) with different values (player)

LLIST supports duplicate values but it in Beta.

The alternative mechanism would be making the key score_id string which should give you keys sorted based on score, and appending id makes it unique as well. You can perform range query to get all the id with particular score …

– R

1 Like

By beta, you mean to say, it will be supported in Aerospike v4?? Great idea to convert the score to string and then appending it with the playerID. Thanks!

Beta means it works but there may be lingering bugs :). It should get become GA in future … (no timelines though)

– R

1 Like