Complete the code to start watching a key for optimistic locking.
redis_client.[1]('mykey')
The watch command tells Redis to monitor the key for changes before executing a transaction.
Complete the code to start a transaction after watching keys.
redis_client.[1]()The multi command starts a transaction block in Redis after watching keys.
Fix the error in the code to execute the transaction and release the watch.
redis_client.[1]()The exec command executes all queued commands in the transaction and releases the watch.
Fill both blanks to unwatch keys and discard the transaction.
redis_client.[1]() redis_client.[2]()
UNWATCH stops watching keys without executing the transaction, and DISCARD cancels the transaction queue.
Fill all three blanks to watch a key, start a transaction, and execute it.
redis_client.[1]('counter') redis_client.[2]() redis_client.[3]()
First, WATCH monitors the key. Then, MULTI starts the transaction. Finally, EXEC runs the queued commands.