I've a Redis cluster v7.x with 3 masters each having a slave. I've defined a Lua function as following:
local keyGet = redis.call('GET', timeSlotKey)
local currentValue = 0
if keyGet ~= nil then
currentValue = tonumber(keyGet)
else
currentValue = 0
end
redis.log(redis.LOG_NOTICE, currentValue)
if currentValue < 5 then
redis.call('INCR', timeSlotKey)
redis.call('EXPIRE', timeSlotKey, expiryDuration)
return 1
else
return 0
end
When I call the function from command line it throws an error:
attempt to compare nil with number
at line if currentValue < 5 then
What is the issue here? How to use the return value of GET call from the Redis?
Finally, after trying other things, I added
redis.setresp(3)
inside the lua function and it is working now.