โ Redis learning pathRedis ยท Module 5 of 10
Sorted sets and leaderboards
Sorted sets keep members ordered by a score.
๐ Key ideas
- ZADD board 120 asha adds a member with a score.
- ZINCRBY adds points to a member atomically.
- ZREVRANGE board 0 9 WITHSCORES returns the top 10.
- ZRANK and ZREVRANK give a member's position.
- 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