aboutsummaryrefslogtreecommitdiffstats
path: root/lualib/rspamadm/configwizard.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 14:00:09 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-02-26 14:00:09 +0000
commit66c4eda320e6a7d7e3d55a3868c1197941d9c259 (patch)
treebb0d0500cf5f8cd510446c8a0c9a9d96ee809a5f /lualib/rspamadm/configwizard.lua
parentac04a740a831c712c93bacb40a4a230131c89281 (diff)
downloadrspamd-66c4eda320e6a7d7e3d55a3868c1197941d9c259.tar.gz
rspamd-66c4eda320e6a7d7e3d55a3868c1197941d9c259.zip
[Feature] Add TTL autodetection
Diffstat (limited to 'lualib/rspamadm/configwizard.lua')
-rw-r--r--lualib/rspamadm/configwizard.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/lualib/rspamadm/configwizard.lua b/lualib/rspamadm/configwizard.lua
index b5bff38ce..f4feab9e7 100644
--- a/lualib/rspamadm/configwizard.lua
+++ b/lualib/rspamadm/configwizard.lua
@@ -370,6 +370,27 @@ return ver
return tonumber(ver)
end
+ local function check_expire()
+ local _,conn = lua_redis.redis_connect_sync(parsed_redis, true)
+ -- We still need to check versions
+ local lua_script = [[
+local ttl = 0
+
+local sc = redis.call('SCAN', 0, 'MATCH', 'RS*_*', 'COUNT', 1)
+local _,key = sc[1], sc[2]
+
+if key and key[1] then
+ ttl = redis.call('TTL', key[1])
+end
+
+return ttl
+]]
+ conn:add_cmd('EVAL', {lua_script, '0'})
+ local _,ttl = conn:exec()
+
+ return tonumber(ttl)
+ end
+
if not cls.new_schema then
local ver = get_version()
@@ -385,6 +406,7 @@ return ver
new_schema = true,
}
+ local expire = check_expire()
if expire then
changes.l['classifier_bayes'].expire = expire
end