Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to start a Redis transaction.
Redis
redis_client.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pipeline() instead of multi() to start a transaction
Confusing exec() as the start command
✗ Incorrect
The MULTI command starts a Redis transaction block.
2fill in blank
mediumComplete the code to execute all commands in a Redis pipeline.
Redis
pipe = redis_client.[1]() pipe.set('key', 'value') pipe.get('key') pipe.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multi() instead of pipeline() to batch commands
Calling exec() before creating the pipeline
✗ Incorrect
The pipeline() method creates a pipeline object to batch commands. The execute() method executes them all at once.
3fill in blank
hardFix the error in the code to execute a Redis transaction.
Redis
pipe = redis_client.multi() pipe.set('key', 'value') pipe.get('key') pipe.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Calling multi() again instead of exec() to run the transaction
Using pipeline() instead of exec() to execute
✗ Incorrect
The EXEC command executes all commands queued in the transaction.
4fill in blank
hardFill both blanks to create a Redis transaction and execute it.
Redis
pipe = redis_client.[1]() pipe.set('count', 1) pipe.incr('count') pipe.[2]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using pipeline() instead of multi() to start
Forgetting to call exec() to execute
✗ Incorrect
Use MULTI to start the transaction and EXEC to execute it atomically.
5fill in blank
hardFill all three blanks to create a Redis pipeline, queue commands, and execute them.
Redis
pipe = redis_client.[1]() pipe.set('name', 'Alice') pipe.get('name') result = pipe.[2]() print(result[[3]])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using multi() instead of pipeline() for batching
Accessing result with wrong index
Calling exec() before queuing commands
✗ Incorrect
Create a pipeline with pipeline(), execute with exec(), and access the first result with index 0.