aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-11 11:52:46 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-11 11:56:46 +0000
commit014f70501d57e70673bc0c9381ce9880452bf6c8 (patch)
tree8321a5029c3982c7c4861790b00bf841cf81d039 /src/plugins
parent5e4c5657e185a6fd9cde7bebf0af8c8e673c2285 (diff)
downloadrspamd-014f70501d57e70673bc0c9381ce9880452bf6c8.tar.gz
rspamd-014f70501d57e70673bc0c9381ce9880452bf6c8.zip
[Fix] Fix expire rounding
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/lua/bayes_expiry.lua23
1 files changed, 10 insertions, 13 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua
index 97b7ca180..7e6938e67 100644
--- a/src/plugins/lua/bayes_expiry.lua
+++ b/src/plugins/lua/bayes_expiry.lua
@@ -30,7 +30,7 @@ local settings = {
count = 1000, -- check up to 1000 keys on each iteration
threshold = 10, -- require at least 10 occurrences to increase expire
epsilon_common = 0.01, -- eliminate common if spam to ham rate is equal to this epsilon
- common_ttl_divisor = 100, -- how should we discriminate common elements
+ common_ttl_divisor = 10, -- how should we discriminate common elements
significant_factor = 3.0 / 4.0, -- which tokens should we update
classifiers = {},
}
@@ -162,18 +162,15 @@ local expiry_script = [[
if ham > ${threshold} or spam > ${threshold} then
local total = ham + spam
-
- if total > 0 then
- if ham / total > ${significant_factor} or spam / total > ${significant_factor} then
- redis.replicate_commands()
- redis.call('EXPIRE', key, KEYS[2])
- extended = extended + 1
- elseif math.abs(ham - spam) <= total * ${epsilon_common} then
- local ttl = redis.call('TTL', key)
- redis.replicate_commands()
- redis.call('EXPIRE', key, tonumber(ttl) / ${common_ttl_divisor})
- discriminated = discriminated + 1
- end
+ if ham / total > ${significant_factor} or spam / total > ${significant_factor} then
+ redis.replicate_commands()
+ redis.call('EXPIRE', key, math.tointeger(KEYS[2]))
+ extended = extended + 1
+ elseif math.abs(ham - spam) <= total * ${epsilon_common} then
+ local ttl = redis.call('TTL', key)
+ redis.replicate_commands()
+ redis.call('EXPIRE', key, math.tointeger(tonumber(ttl) / ${common_ttl_divisor}))
+ discriminated = discriminated + 1
end
end
nelts = nelts + 1