spacegate-plugin 0.2.0-alpha.4

A library-first, lightweight, high-performance, cloud-native supported API gateway
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local current_count = tonumber(redis.call('incr', KEYS[1]));
if current_count == 1 then
    redis.call('set', KEYS[2], ARGV[3]);
end
if current_count > tonumber(ARGV[1]) then
    local last_refresh_time = tonumber(redis.call('get', KEYS[2]));
    if last_refresh_time + tonumber(ARGV[2]) > tonumber(ARGV[3]) then
        if current_count == tonumber(ARGV[1]) + 1 then
            return 1;
        else 
            return 0;
        end
    end
    redis.call('set', KEYS[1], '1')
    redis.call('set', KEYS[2], ARGV[3]);
end

return 2;