Redis easy
How does a 'Sorted Set' (ZSET) manage its internal membership and ordering differently from a plain Set?
- A It allows for duplicate members as long as they have different associated score values.
- B It associates each unique member with a numerical score used to maintain global sorting.
- C It sorts elements alphabetically based on the raw ASCII bytes of the member string data.
- D It is significantly slower than a standard Set due to the lack of an internal hash table index.
Answer: B. It associates each unique member with a numerical score used to maintain global sorting.
ZSETs are the foundation of gaming leaderboards or rate limiters. Every member is unique, but it has a 'Priority' (Score). You can efficiently fetch ranges (e.g., 'ranks 1 to 10') in O(log N + M) time.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- If the Redis memory limit is reached, what specific behavior is exhibited by the `allkeys-lru` eviction policy?
- What is the defining characteristic of a Redis 'Set' data type compared to a standard Redis 'List'?
- In the context of Redis messaging, what is the functional definition of the 'Pub/Sub' feature?
- How does the Redis background snapshotting process (`BGSAVE`) leverage the operating system's `fork()` mechanism to minimize memory overhead?
- Why does Redis proactively disconnect a Pub/Sub client that exhibits high 'output buffer' usage relative to its ingestion rate?
- Which basic Redis command is used to store or update a simple String value associated with a specific key?