Complete the code to send multiple commands in a pipeline.
pipe = client.pipeline() pipe.[1]('set', 'key1', 'value1') pipe.execute()
The send_command method queues commands in the pipeline before execution.
Complete the code to execute multiple commands individually without pipeline.
client.[1]('set', 'key1', 'value1') client.[1]('set', 'key2', 'value2')
The execute_command method sends a single command to Redis immediately.
Fix the error in the pipeline code to correctly queue commands.
pipe = client.pipeline() pipe.[1]('set', 'key1', 'value1') pipe.[1]('set', 'key2', 'value2') pipe.execute()
Using send_command queues commands in the pipeline correctly before execution.
Fill both blanks to create a pipeline that sets two keys and executes them.
pipe = client.[1]() pipe.[2]('set', 'key1', 'value1') pipe.[2]('set', 'key2', 'value2') pipe.execute()
First, create a pipeline with pipeline(), then queue commands with send_command.
Fill all three blanks to send commands individually and then with pipeline.
client.[1]('set', 'key1', 'value1') client.[1]('set', 'key2', 'value2') pipe = client.[2]() pipe.[3]('set', 'key3', 'value3') pipe.execute()
Use execute_command for individual commands, pipeline() to create a pipeline, and send_command to queue commands in the pipeline.