Search code examples
javaredisredisson

Is it ok to use ScoredSortedSet from Redisson lib to get actual item rank within environment with extensive writes?


I want to use Redis with java Redisson library. I have a task to store items in a sorted order, based on some item's field. There are three main constraints:

  1. Sorting field of items could be updated quite often. There could be up to 25k updates per second for the whole collection.
  2. I need to get an actual rank of each item in my collection very fast (up to 5 ms).
  3. The collection size could be up to 25 millions items.

Is it ok to use Redissons ScoredSortedSet.rank method with such constraints, or it is not suitable and there is a better solution?


Solution

  • Yes everything is possible with ScoredSortedSet (it is mapped to Redis Sorted Set), but I need to convert my field to score so that ScoredSortedSet works. Nikita suggests to use RSortedSet or PriorityQueue, however they do not have 'rank' command, which I needed.