Complete the code to start a Redis transaction.
redis.call('[1]')
The MULTI command starts a Redis transaction block.
Complete the Lua script to atomically increment a key by 1.
return redis.call('[1]', KEYS[1]) + 1
The script uses INCR to atomically increment the key by 1.
Fix the error in the Lua script to ensure atomic increment.
local val = redis.call('[1]', KEYS[1]) if not val then redis.call('[2]', KEYS[1], 1) return 1 end return redis.call('[3]', KEYS[1])
The script first GETs the value. If it doesn't exist, it SETs it to 1. Otherwise, it INCRs the value.
Fill both blanks to watch a key and start a transaction.
redis.call('[1]', KEYS[1]) redis.call('[2]')
You WATCH the key to monitor changes, then start the transaction with MULTI.
Fill all three blanks to execute a transaction with error handling.
redis.call('[1]') local success = redis.call('[2]') if not success then redis.call('[3]') end
You start the transaction with MULTI, execute it with EXEC, and if it fails, cancel with DISCARD.
