Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start a Redis pipeline.
Redis
pipe = client.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'transaction' or 'multi' which are not valid Redis client methods for pipelines.
Trying to use 'batch' which is not a Redis pipeline method.
✗ Incorrect
Use pipeline() to start a Redis pipeline for batching commands.
2fill in blank
mediumComplete the code to execute the Redis pipeline and get results.
Redis
results = pipe.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'commit' which are not Redis pipeline methods.
Using 'send' which does not return results.
✗ Incorrect
The execute() method sends all commands in the pipeline to Redis and returns their results.
3fill in blank
hardFix the error in the code to catch pipeline errors properly.
Redis
try: pipe.[1]() except [2] as e: print('Pipeline error:', e)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'execute' causes AttributeError.
Catching 'PipelineError' which may not exist in the client library.
✗ Incorrect
Use execute() to run the pipeline and catch RedisError for errors.
4fill in blank
hardFill both blanks to add commands to the pipeline and execute it safely.
Redis
pipe.[1]('key', 'value') pipe.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to execute before adding commands.
Using 'get' instead of 'set' to add a command.
✗ Incorrect
Use set to add a command and execute to run the pipeline.
5fill in blank
hardFill all three blanks to handle errors during pipeline execution and print results.
Redis
try: results = pipe.[1]() print('Results:', results) except [2] as [3]: print('Error:', e)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' instead of 'execute' causes errors.
Catching wrong exception types or missing exception variable.
✗ Incorrect
Use execute() to run the pipeline, catch RedisError, and name the exception e.