Challenge - 5 Problems
Sorted Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate2:00remaining
Why do Redis sorted sets enforce uniqueness of members?
Redis sorted sets require each member to be unique. Why is this important for their functionality?
Attempts:
2 left
💡 Hint
Think about how ordering works when members can have scores.
✗ Incorrect
Each member in a sorted set must be unique so that it can have exactly one score. This allows Redis to order members by their scores without confusion or duplicates.
❓ query_result
intermediate2:00remaining
What is the output of ZRANGE with scores on a sorted set?
Given a sorted set with members and scores, what does the command `ZRANGE myset 0 -1 WITHSCORES` return?
Redis
ZADD myset 10 "apple" 20 "banana" 15 "cherry" ZRANGE myset 0 -1 WITHSCORES
Attempts:
2 left
💡 Hint
ZRANGE returns members ordered by score from lowest to highest.
✗ Incorrect
ZRANGE with WITHSCORES returns members sorted by their scores ascending, paired with their scores as strings.
📝 Syntax
advanced2:00remaining
Identify the syntax error in this sorted set command
Which option contains a syntax error when adding members to a sorted set?
Redis
ZADD myset 10 "apple" 20 "banana" 15 "cherry"
Attempts:
2 left
💡 Hint
Check if all scores have corresponding members.
✗ Incorrect
Option B is missing a member after the last score 15, causing a syntax error.
❓ optimization
advanced2:00remaining
How to efficiently update scores in a large sorted set?
You want to update scores of multiple members in a large Redis sorted set. Which approach is most efficient?
Attempts:
2 left
💡 Hint
Consider network round trips and command overhead.
✗ Incorrect
Sending one ZADD command with all pairs reduces network overhead and is more efficient than multiple commands.
🔧 Debug
expert2:00remaining
Why does this ZRANK command return nil unexpectedly?
You added members to a sorted set but `ZRANK myset "orange"` returns nil. What is the most likely cause?
Attempts:
2 left
💡 Hint
ZRANK returns nil if the member is not found in the set.
✗ Incorrect
If the member is not present in the sorted set, ZRANK returns nil. Having a zero score does not cause nil.