Challenge - 5 Problems
Redis ZSCORE Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of ZSCORE for an existing member?
Given a sorted set named
players with members and their scores, what will be the output of ZSCORE players "Alice" if Alice's score is 1500?Redis
ZADD players 1500 Alice ZSCORE players "Alice"
Attempts:
2 left
💡 Hint
Remember that ZSCORE returns the score as a string if the member exists.
✗ Incorrect
The ZSCORE command returns the score of the specified member as a string if the member exists in the sorted set. If the member does not exist, it returns nil.
❓ query_result
intermediate2:00remaining
What does ZSCORE return for a non-existing member?
If you run
ZSCORE players "Bob" but Bob is not in the sorted set, what will Redis return?Redis
ZADD players 1500 Alice ZSCORE players "Bob"
Attempts:
2 left
💡 Hint
Think about what Redis returns when a member is missing in a sorted set.
✗ Incorrect
When the member does not exist in the sorted set, ZSCORE returns nil to indicate absence.
🧠 Conceptual
advanced2:00remaining
Why does ZSCORE return scores as strings?
Which reason best explains why Redis returns the score as a string when using ZSCORE?
Attempts:
2 left
💡 Hint
Think about how Redis handles data types and communication.
✗ Incorrect
Redis stores and transmits data as strings to keep things simple and fast. Even numeric scores are sent as strings.
📝 Syntax
advanced2:00remaining
Which ZSCORE command syntax is correct?
Choose the correct syntax to get the score of member "Charlie" from sorted set "game_scores".
Attempts:
2 left
💡 Hint
Member names with special characters or spaces need quotes.
✗ Incorrect
The correct syntax requires the sorted set name without quotes and the member name in quotes if it contains special characters or to be safe.
❓ optimization
expert3:00remaining
How to efficiently check scores of multiple members?
You want to get scores for multiple members in a sorted set efficiently. Which approach is best?
Attempts:
2 left
💡 Hint
Think about reducing network round-trips and server load.
✗ Incorrect
Redis does not support multiple members in one ZSCORE command. Running many commands separately causes many network calls. Using a Lua script batches calls inside Redis, reducing network overhead and improving performance.