Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start a Redis pipeline.
Redis
pipe = redis_client.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'transaction' instead of 'pipeline' causes errors because Redis uses 'pipeline()' method.
Using 'multi' or 'batch' are not valid Redis client methods.
✗ Incorrect
Use pipeline() to start a Redis pipeline for batching commands.
2fill in blank
mediumComplete the code to add a command to the pipeline.
Redis
pipe.[1]('key', 'value')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to use 'execute' to add commands is wrong; 'execute' runs all commands.
Using 'add' or 'append' are not Redis pipeline methods.
✗ Incorrect
Use the Redis command name like set on the pipeline object to queue it.
3fill in blank
hardFix the error in the code to run all pipeline commands.
Redis
result = pipe.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' or 'commit' causes AttributeError because those methods don't exist.
Using 'send' is not a Redis pipeline method.
✗ Incorrect
The execute() method runs all queued commands in the pipeline.
4fill in blank
hardFill both blanks to create and execute a pipeline that sets two keys.
Redis
pipe = redis_client.[1]() pipe.set('key1', 'val1') pipe.set('key2', 'val2') result = pipe.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'transaction' instead of 'pipeline' causes errors.
Using 'run' instead of 'execute' to run commands causes AttributeError.
✗ Incorrect
Start with pipeline() and finish with execute() to run all commands.
5fill in blank
hardFill all three blanks to create a pipeline, add a command, and execute it.
Redis
pipe = redis_client.[1]() pipe.[2]('counter', 1) result = pipe.[3]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'increment' instead of 'incrby' causes errors.
Using 'run' instead of 'execute' causes AttributeError.
✗ Incorrect
Use pipeline() to start, incrby to increment, and execute() to run commands.