Complete the Lua script to increment a Redis key atomically.
redis.call('[1]', KEYS[1])
The incr command increments the integer value of a key by one atomically.
Complete the Lua script to set a key only if it does not exist.
redis.call('[1]', KEYS[1], ARGV[1])
The setnx command sets the key only if it does not already exist, ensuring atomicity.
Fix the error in the Lua script to decrement a key's value atomically.
redis.call('[1]', KEYS[1])
The decr command atomically decrements the integer value of a key by one.
Fill both blanks to atomically add a member to a set and set an expiration time.
redis.call('[1]', KEYS[1], ARGV[1]) redis.call('[2]', KEYS[1], tonumber(ARGV[2]))
sadd adds a member to a set atomically, and expire sets the key's time to live.
Fill all three blanks to atomically increment a hash field, check its value, and delete the key if zero.
local newVal = redis.call('[1]', KEYS[1], ARGV[1], 1) if newVal == tonumber('[2]') then redis.call('[3]', KEYS[1]) end
hincrby increments a hash field atomically, then we check if the value is zero, and del deletes the key if so.