Complete the code to start a Redis transaction.
redis.call('[1]')
The MULTI command starts a Redis transaction block.
Complete the code to execute all commands queued in a Redis transaction.
redis.call('[1]')
The EXEC command executes all commands queued in the current transaction.
Fix the error in the Lua script to atomically increment a key and return its new value.
local newVal = redis.call('INCR', '[1]') return newVal
The key name to increment must be provided as a string, here 'counter'.
Fill both blanks to watch a key and start a transaction in Redis.
redis.call('[1]', 'mykey') redis.call('[2]')
WATCH monitors the key for changes, and MULTI starts the transaction.
Fill all three blanks to write a Lua script that increments a key only if it has not changed since watching it.
redis.call('[1]', KEYS[1]) redis.call('[2]') redis.call('INCR', KEYS[1]) local val = redis.call('[3]') return val[1]
The script watches the key, starts a transaction, increments the key, then executes the transaction.
