local function get_cur_time()
local current_time = redis.call('TIME')[1]
local current_minute_start = math.floor(current_time / 60) * 60
return current_minute_start
end
-- add below line would failed
-- local CURRENT_TIME = get_cur_time()
redis.register_function('get_cur_time', get_cur_time)
I’d like reuse CURRENT_TIME
in many place in my function, but once I added it to global scope, raise error:
redis.exceptions.ResponseError: Error registering functions: ERR user_function:6: Script attempted to access nonexistent global variable 'call'
Anyway to get around?