0
0
Redisquery~20 mins

Why sorted sets combine uniqueness with ordering in Redis - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Sorted Set Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2: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?
ATo store duplicate members with different scores
BTo allow multiple scores for the same member
CTo ensure each member has a single, well-defined score for ordering
DTo improve network transfer speed by compressing duplicates
Attempts:
2 left
💡 Hint
Think about how ordering works when members can have scores.
query_result
intermediate
2: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
A["apple", "10", "cherry", "15", "banana", "20"]
B["banana", "20", "cherry", "15", "apple", "10"]
C["cherry", "15", "apple", "10", "banana", "20"]
D["apple", "10", "banana", "20", "cherry", "15"]
Attempts:
2 left
💡 Hint
ZRANGE returns members ordered by score from lowest to highest.
📝 Syntax
advanced
2: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"
AZADD myset "10" "apple" "20" "banana" "15" "cherry"
BZADD myset 10 "apple" 20 "banana" 15
CZADD myset 10 apple 20 banana 15 cherry
DZADD myset 10 "apple" 20 "banana" 15 "cherry"
Attempts:
2 left
💡 Hint
Check if all scores have corresponding members.
optimization
advanced
2: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?
AUse ZINCRBY for each member to add the new score
BUse multiple ZADD commands, one per member
CDelete the sorted set and recreate it with new scores
DUse a single ZADD command with all member-score pairs
Attempts:
2 left
💡 Hint
Consider network round trips and command overhead.
🔧 Debug
expert
2: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?
AThe member "orange" was never added to the sorted set
BThe sorted set key "myset" does not exist
CThe member "orange" has a score of zero
DZRANK only works with string keys, not sorted sets
Attempts:
2 left
💡 Hint
ZRANK returns nil if the member is not found in the set.