local max_burst = tonumber(KEYS[4])
local prefix = KEYS[1]
local enable_dynamic = KEYS[7] == 'true'
-local cache_prefix = KEYS[8]
-local max_cache_size = KEYS[9]
+local lfb_cache_prefix = KEYS[8]
+local lfb_max_cache_size = tonumber(KEYS[9])
local dynr, dynb, leaked = 0, 0, 0
if not last then
-- New bucket
burst = burst + pending
if burst > 0 and burst > max_burst * dynb then
- redis.call('ZREMRANGEBYRANK', cache_prefix, 0, -(max_cache_size + 1))
- redis.call('ZADD', cache_prefix, now, prefix) -- LRU cache is based on timestamps of buckets
+ redis.call('ZREMRANGEBYRANK', lfb_cache_prefix, 0, -(lfb_max_cache_size + 1)) -- Keeping size of lfb cache
+ redis.call('ZADD', lfb_cache_prefix, now, prefix) -- LRU cache is based on timestamps of buckets
return { 1, tostring(burst - pending), tostring(dynr), tostring(dynb), tostring(leaked) }
end
-- Do not check ratelimits for these recipients
whitelisted_rcpts = { 'postmaster', 'mailer-daemon' },
prefix = 'RL',
- cache_prefix = 'RL_cache_prefix',
- max_cache_size = 30,
+ lfb_cache_prefix = 'RL_cache_prefix', -- Last filled buckets cache prefix
+ lfb_max_cache_size = 30,
-- If enabled, we apply dynamic rate limiting based on the verdict
dynamic_rate_limit = false,
ham_factor_rate = 1.01,
for pr, value in pairs(prefixes) do
local bucket = value.bucket
- local rate = (bucket.rate) / 1000.0 -- Leak rate in messages/ms
+ local rate = (bucket.rate) / 1000.0 -- Leak rate in messast filled bucketsages/ms
local bincr = nrcpt
if bucket.skip_recipients then
bincr = 1
gen_check_cb(pr, bucket, value.name, value.hash),
{ value.hash, tostring(now), tostring(rate), tostring(bucket.burst),
tostring(settings.expire), tostring(bincr), tostring(dyn_rate_enabled),
- settings.cache_prefix, settings.max_cache_size })
+ tostring(settings.lfb_cache_prefix), tostring(settings.lfb_max_cache_size) })
end
end
end