const CHECK_AND_INCREMENT_LUA: &str = r#"
local current = tonumber(redis.call('GET', KEYS[1]) or '0')
local limit = tonumber(ARGV[1])
local ttl = tonumber(ARGV[2])
if current < limit then
current = redis.call('INCR', KEYS[1])
redis.call('EXPIRE', KEYS[1], ttl)
return {current, 1}
end
return {current, 0}
"#;Expand description
Lua script for atomic check-and-increment in Redis. Returns {current_count, allowed (1=yes, 0=no)}