local rate = tonumber(ARGV[1]);
local rateInterval = tonumber(ARGV[2]);
local limitResult = 0;
local ttlResult = 0;
local currValue = redis.call('incr', KEYS[1]);
if (currValue == 1) then
redis.call('expire', KEYS[1], rateInterval);
limitResult = 0;
else
if (currValue > rate) then
limitResult = 1;
ttlResult = redis.call('ttl', KEYS[1]);
end
end
return { limitResult, ttlResult }