diff options
author | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-04-21 19:17:12 +0300 |
---|---|---|
committer | Alexander Moisseev <moiseev@mezonplus.ru> | 2018-04-21 19:17:12 +0300 |
commit | 3c69fb32830fb2f6b9b06ad7ab2fead99278afc1 (patch) | |
tree | 756b977e3e81879f41577a7fcd64501ae9cbefe3 | |
parent | efcf01e0ccce18db3346c3c136a31fbae6f28ada (diff) | |
download | rspamd-3c69fb32830fb2f6b9b06ad7ab2fead99278afc1.tar.gz rspamd-3c69fb32830fb2f6b9b06ad7ab2fead99278afc1.zip |
[Minor] Properly merge Redis hash into a table
-rw-r--r-- | src/plugins/lua/bayes_expiry.lua | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua index 5a67bd90a..4f4d810bb 100644 --- a/src/plugins/lua/bayes_expiry.lua +++ b/src/plugins/lua/bayes_expiry.lua @@ -178,21 +178,15 @@ local expiry_script = [[ return res end - local function list2hash(list) - local res = {} + local function merge_list(table, list) local k for i, v in ipairs(list) do if i % 2 == 1 then k = v else - res[k] = v + table[k] = v end end - if not k then - return - else - return res - end end local expire = math.floor(KEYS[2]) @@ -297,8 +291,7 @@ local expiry_script = [[ local counters_key = pattern_sha1 .. '_counters' if cursor ~= 0 then - local counters = list2hash(redis.call('HGETALL', counters_key)) - if counters then c = counters end + merge_list(c, redis.call('HGETALL', counters_key)) end c.nelts = c.nelts + nelts |