Lua will automatically convert string and number types to the correct format to perform calculations. (...) A notable exception: comparison operators (== ~= < > <= >=) do not coerce their arguments.
Consider:
127.0.0.1:6379> SET test 50
OK
127.0.0.1:6379> EVAL "local newvalue = tonumber(redis.call('GET', KEYS[1])) if newvalue < tonumber(ARGV[1]) then return redis.call('SET', KEYS[1], ARGV[1]) else return nil end" 1 test 6
(nil)
vs. the script in the current form:
127.0.0.1:6379> SET test 50
OK
127.0.0.1:6379> EVAL "local newvalue = redis.call('GET', KEYS[1]) if newvalue < ARGV[1] then return redis.call('SET', KEYS[1], ARGV[1]) else return nil end" 1 test 6
OK
This script runs only when reconnecting to Redis.
Lua will automatically convert string and number types to the correct format to perform calculations. (...) A notable exception: comparison operators (== ~= < > <= >=) do not coerce their arguments.
Consider:
vs. the script in the current form:
This script runs only when reconnecting to Redis.