Challenge - 5 Problems
Redis Pipeline Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What happens when a Redis pipeline contains a command with a syntax error?
Consider this Redis pipeline with three commands:
1. SET key1 value1
2. INCR key1
3. GET key1
What will be the result of executing this pipeline?
1. SET key1 value1
2. INCR key1
3. GET key1
What will be the result of executing this pipeline?
Redis
redis> SET key1 value1 redis> INCR key1 redis> GET key1
Attempts:
2 left
💡 Hint
Remember that INCR expects a numeric value and key1 was set to a string.
✗ Incorrect
The SET command sets key1 to a string value. The INCR command tries to increment key1, but since key1 is not an integer, it returns an error. The GET command still returns the string value set by SET. The pipeline does not fail entirely; errors are returned per command.
🧠 Conceptual
intermediate2:00remaining
How does Redis pipeline handle errors inside MULTI/EXEC transactions?
In a Redis transaction using MULTI/EXEC, if one command inside the transaction has a syntax error, what happens when EXEC is called?
Attempts:
2 left
💡 Hint
Think about how Redis queues commands in a transaction before execution.
✗ Incorrect
Syntax errors are detected at enqueue time after MULTI; the erroneous command is not queued, but EXEC executes all valid queued commands.
🔧 Debug
advanced2:00remaining
Identify the error in this Redis pipeline usage
A developer writes this Redis pipeline code:
pipe = redis.pipeline()
pipe.set('count', 'ten')
pipe.incr('count')
pipe.get('count')
results = pipe.execute()
What error will occur when executing this pipeline?
pipe = redis.pipeline()
pipe.set('count', 'ten')
pipe.incr('count')
pipe.get('count')
results = pipe.execute()
What error will occur when executing this pipeline?
Redis
pipe = redis.pipeline() pipe.set('count', 'ten') pipe.incr('count') pipe.get('count') results = pipe.execute()
Attempts:
2 left
💡 Hint
INCR expects the key to hold an integer value.
✗ Incorrect
The SET command sets 'count' to the string 'ten'. The INCR command tries to increment 'count' but fails because 'ten' is not an integer. The pipeline.execute() returns a list where the second item is an error object.
📝 Syntax
advanced2:00remaining
Which pipeline command sequence will cause a runtime error?
Given these Redis pipeline commands, which sequence will cause a runtime error when executed?
Attempts:
2 left
💡 Hint
INCR only works on keys holding integer values.
✗ Incorrect
Option C sets key2 to a string 'hello'. INCR on a string value causes a runtime error. Other options use integer-compatible commands or valid operations.
❓ optimization
expert3:00remaining
Optimizing error handling in Redis pipelines
You want to execute multiple Redis commands in a pipeline and handle errors gracefully without stopping the entire pipeline. Which approach is best?
Attempts:
2 left
💡 Hint
Pipelines batch commands but do not stop on errors automatically.
✗ Incorrect
Pipelines send commands in batch and return results including errors per command. Checking results after execution allows graceful error handling without stopping the entire batch.