local key = KEYS local jid = ARGV local lmt = tonumber(ARGV) local ttl = tonumber(ARGV) local now = tonumber(ARGV)

redis.call(“ZREMRANGEBYSCORE”, key, “-inf”, “(” .. now)

if lmt <= redis.call(“ZCARD”, key) and not redis.call(“ZSCORE”, key, jid) then

return 1

end

redis.call(“ZADD”, key, now + ttl, jid) redis.call(“EXPIRE”, key, ttl)

return 0