Challenge - 5 Problems
ZINCRBY Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the new score of 'player1' after this command?
Given a sorted set 'game_scores' with 'player1' having a score of 50, what will be the score of 'player1' after running:
ZINCRBY game_scores 20 player1Redis
ZINCRBY game_scores 20 player1Attempts:
2 left
💡 Hint
ZINCRBY adds the increment to the current score of the member.
✗ Incorrect
ZINCRBY increases the score of 'player1' by 20. Since the original score was 50, the new score is 70.
❓ query_result
intermediate1:30remaining
What happens if the member does not exist?
What will be the result of running:
when 'playerX' is not in the sorted set 'game_scores'?
ZINCRBY game_scores 15 playerXwhen 'playerX' is not in the sorted set 'game_scores'?
Redis
ZINCRBY game_scores 15 playerXAttempts:
2 left
💡 Hint
ZINCRBY adds the member if it does not exist, starting with the increment as score.
✗ Incorrect
If the member does not exist, ZINCRBY adds it with the increment as its score, so the score becomes 15.
📝 Syntax
advanced1:30remaining
Which command syntax is correct to increase 'player2' score by 10?
Choose the correct Redis command to increase the score of 'player2' by 10 in the sorted set 'game_scores'.
Attempts:
2 left
💡 Hint
The syntax is ZINCRBY key increment member.
✗ Incorrect
The correct syntax is ZINCRBY followed by the key, then the increment, then the member name.
❓ optimization
advanced2:00remaining
How to efficiently update multiple player scores?
You want to increase scores of multiple players in 'game_scores' by different amounts. Which approach is best for performance?
Attempts:
2 left
💡 Hint
Pipelining reduces network round trips.
✗ Incorrect
Redis pipelines allow sending multiple commands in one go, reducing latency and improving performance.
🧠 Conceptual
expert2:00remaining
What is the effect of using a negative increment with ZINCRBY?
If you run:
and 'player3' has a current score of 25, what will be the new score and what happens if the score becomes negative?
ZINCRBY game_scores -30 player3and 'player3' has a current score of 25, what will be the new score and what happens if the score becomes negative?
Attempts:
2 left
💡 Hint
Redis sorted sets can have negative scores.
✗ Incorrect
ZINCRBY allows negative increments and scores can be negative; Redis does not remove members or clamp scores automatically.