Challenge - 5 Problems
Redis Increment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the result of INCRBY on a key with an integer value?
Given a Redis key
counter with value 10, what will be the value of counter after running INCRBY counter 5?Redis
SET counter 10 INCRBY counter 5 GET counter
Attempts:
2 left
💡 Hint
INCRBY adds the given number to the current integer value stored at the key.
✗ Incorrect
The INCRBY command increases the integer value stored at the key by the specified amount. Since the initial value is 10, adding 5 results in 15.
❓ query_result
intermediate1:30remaining
What happens when DECRBY is used on a non-existing key?
What will be the value of key
score after running DECRBY score 3 if score does not exist before?Redis
DEL score
DECRBY score 3
GET scoreAttempts:
2 left
💡 Hint
Redis treats non-existing keys as 0 for increment/decrement commands.
✗ Incorrect
If the key does not exist, Redis treats its value as 0. Then DECRBY score 3 subtracts 3, resulting in -3.
📝 Syntax
advanced1:00remaining
Which command syntax is correct for incrementing a key by 10?
Choose the correct Redis command to increase the value of key
visits by 10.Attempts:
2 left
💡 Hint
The syntax is
INCRBY key increment.✗ Incorrect
The correct syntax for incrementing a key by a specific number is INCRBY key increment. Options B, C, and D are invalid syntax.
❓ query_result
advanced1:30remaining
What error occurs when INCRBY is used on a key holding a string?
If key
name holds the string value "Alice", what happens when running INCRBY name 1?Redis
SET name "Alice" INCRBY name 1
Attempts:
2 left
💡 Hint
INCRBY only works on keys holding integer values.
✗ Incorrect
Redis throws an error if you try to increment a key holding a non-integer string value.
🧠 Conceptual
expert2:00remaining
How does Redis handle concurrent INCRBY and DECRBY commands on the same key?
Consider multiple clients running
INCRBY counter 2 and DECRBY counter 1 concurrently on the same key counter. What guarantees does Redis provide about the final value?Attempts:
2 left
💡 Hint
Redis commands like INCRBY and DECRBY are atomic operations.
✗ Incorrect
Redis processes commands sequentially and atomically, so concurrent INCRBY and DECRBY commands on the same key do not cause race conditions. The final value reflects all operations applied in some order.