0
0
Redisquery~5 mins

INCRBY and DECRBY in Redis - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
AReturn an error
BDo nothing
CSet the key to the increment value
DDelete the key
Which command decreases the value of a key by a specified number?
ADECRBY
BAPPEND
CINCR
DINCRBY
What type of value must a key hold to use INCRBY successfully?
AInteger
BList
CString
DSet
If you run DECRBY key 5 on a key with value 3, what will be the new value?
A8
B-2
C0
D5
Which command would you use to increase a key's value by 1 in Redis?
AAPPEND key 1
BDECRBY key 1
CSET key 1
DINCRBY key 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.