โ† Redis learning path
Redis ยท Module 5 of 10

Sorted sets and leaderboards

Sorted sets keep members ordered by a score.

๐Ÿ“– Key ideas

  1. ZADD board 120 asha adds a member with a score.
  2. ZINCRBY adds points to a member atomically.
  3. ZREVRANGE board 0 9 WITHSCORES returns the top 10.
  4. ZRANK and ZREVRANK give a member's position.
  5. Scores can be timestamps, making time-ordered feeds.
๐Ÿ’ก Real-life example: Like a cricket points table that re-sorts itself every time a team wins.
ZADDAdd a member with a score
ZINCRBYIncrease a member's score
ZREVRANGEMembers from highest score down
ZREVRANKPosition counted from the top