diff options
author | LeftTry <lerest.go@gmail.com> | 2024-09-29 12:23:46 +0600 |
---|---|---|
committer | LeftTry <lerest.go@gmail.com> | 2024-09-29 12:23:46 +0600 |
commit | c4386c6ab0d649d3b999f0cf98f6fccea9212ce5 (patch) | |
tree | 0e019ab408058c94557b3d215fab4ad7fe58191f /src/plugins/lua/ratelimit.lua | |
parent | 985351866363c45c54e4cfeb6c3dee16caf39e75 (diff) | |
download | rspamd-c4386c6ab0d649d3b999f0cf98f6fccea9212ce5.tar.gz rspamd-c4386c6ab0d649d3b999f0cf98f6fccea9212ce5.zip |
[Feature] Add LRU cache for last filled ratelimit buckets
Diffstat (limited to 'src/plugins/lua/ratelimit.lua')
-rw-r--r-- | src/plugins/lua/ratelimit.lua | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/plugins/lua/ratelimit.lua b/src/plugins/lua/ratelimit.lua index 168d8d63a..c0783eac8 100644 --- a/src/plugins/lua/ratelimit.lua +++ b/src/plugins/lua/ratelimit.lua @@ -41,6 +41,8 @@ local settings = { -- Do not check ratelimits for these recipients whitelisted_rcpts = { 'postmaster', 'mailer-daemon' }, prefix = 'RL', + cache_prefix = 'RL_cache_prefix', + max_cache_size = 30, -- If enabled, we apply dynamic rate limiting based on the verdict dynamic_rate_limit = false, ham_factor_rate = 1.01, @@ -455,7 +457,8 @@ local function ratelimit_cb(task) { key = value.hash, task = task, is_write = true }, 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) }) + tostring(settings.expire), tostring(bincr), tostring(dyn_rate_enabled), + settings.cache_prefix, settings.max_cache_size }) end end end |