Recall & Review
beginner
What does the Redis command INCRBY do?
INCRBY increases the integer value of a key by a specified amount. If the key does not exist, it is set to 0 before the operation.
Click to reveal answer
beginner
How does DECRBY differ from INCRBY in Redis?
DECRBY decreases the integer value of a key by a specified amount, while INCRBY increases it.
Click to reveal answer
intermediate
What happens if you use INCRBY on a key that holds a non-integer value?
Redis returns an error because INCRBY only works on keys holding string values that represent integers.
Click to reveal answer
beginner
Can INCRBY and DECRBY be used on keys that do not exist?
Yes, Redis treats non-existing keys as 0 before applying INCRBY or DECRBY.
Click to reveal answer
beginner
Write a Redis command to increase the value of key 'score' by 10.
INCRBY score 10
Click to reveal answer
What will Redis do if you run INCRBY on a key that does not exist?
✗ Incorrect
Redis treats non-existing keys as 0, then adds the increment value.
Which command decreases the value of a key by a specified number?
✗ Incorrect
DECRBY decreases the integer value of a key by the given amount.
What type of value must a key hold to use INCRBY successfully?
✗ Incorrect
INCRBY works only on keys holding integer values.
If you run DECRBY key 5 on a key with value 3, what will be the new value?
✗ Incorrect
3 minus 5 equals -2.
Which command would you use to increase a key's value by 1 in Redis?
✗ Incorrect
INCRBY key 1 increases the key's value by 1.
Explain how INCRBY and DECRBY work in Redis and what happens if the key does not exist.
Think about how Redis handles missing keys as zero.
You got /3 concepts.
Describe what error conditions might occur when using INCRBY or DECRBY.
Consider the data type Redis expects for these commands.
You got /2 concepts.