aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVitaliy Vasilenko <me@vitalvas.com>2022-05-21 16:30:25 +0300
committerVitaliy Vasilenko <me@vitalvas.com>2022-05-21 16:30:25 +0300
commit581ff8e565d65905c8d9710df28188788e050af0 (patch)
treeb575fcef67d023ffcc7a79e21fc86a3349bd997c /src/plugins
parent63e180d7d377c48d9353b8ce385c3fcddf438ffe (diff)
downloadrspamd-581ff8e565d65905c8d9710df28188788e050af0.tar.gz
rspamd-581ff8e565d65905c8d9710df28188788e050af0.zip
[Enhancement] Add expire to history redis
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/history_redis.lua10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/plugins/lua/history_redis.lua b/src/plugins/lua/history_redis.lua
index e669cb919..d0223dd88 100644
--- a/src/plugins/lua/history_redis.lua
+++ b/src/plugins/lua/history_redis.lua
@@ -21,6 +21,8 @@ if confighelp then
redis_history {
# History key name
key_prefix = 'rs_history';
+ # History expire in seconds
+ expire = 0;
# History rows limit
nrows = 200;
# Use zstd compression when storing data in redis
@@ -42,6 +44,7 @@ local redis_params
local settings = {
key_prefix = 'rs_history', -- default key name
+ expire = 0, -- default no expire
nrows = 200, -- default rows limit
compress = true, -- use zstd compression when storing data in redis
subject_privacy = false, -- subject privacy is off
@@ -153,7 +156,12 @@ local function history_save(task)
if ret then
conn:add_cmd('LTRIM', {prefix, '0', string.format('%d', settings.nrows-1)})
- conn:add_cmd('SADD', {settings.key_prefix, prefix})
+
+ if settings.expire > 0 then
+ conn:add_cmd('EXPIRE', {prefix, string.format('%d', settings.expire)})
+ else
+ conn:add_cmd('SADD', {settings.key_prefix, prefix})
+ end
end
end