Software Engineering :: Database :: Redis :: Data Structure :: Sorted Sets (ZSet)
⪼ Made with 💜 by Polyglot.
A sorted set is an ordered collection of unique members and an associated score.
- Priority Queues
- Low-Latency Game Leaderboard (i.e. experience points)
- Secondary Indexing
- Responsive
- In-Memory Structure (Low-Latency)
-
ZADD: Adds all the specified members with the specified scores to the sorted set stored at key. -
ZINCRBY: Increments the score of member in the sorted set stored at key by increment. -
ZRANK: Returns the rank of member in the sorted set stored at key, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0. -
ZREVRANK: Returns the rank of member in the sorted set stored at key, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0. -
ZRANGE: Returns the specified range of elements in the sorted set stored at<key>. -
ZSCORE: Returns the score of member in the sorted set at key.
ZADD <KEY> <SCORE> <MEMBER>
ZINCRBY <KEY> <INCREMENT> <MEMBER>
ZRANGE <KEY> <START> <END> REV BYSCORE
ZRANK <KEY> <MEMBER> [WITHSCORE]
ZREVRANK <KEY> <MEMBER> [WITHSCORE]
ZSCORE <KEY> <SCORE>
- Display the TOP 10 players
- See a player's rank
- See a player's score