From: Alexander Moisseev Date: Sat, 21 Apr 2018 16:17:12 +0000 (+0300) Subject: [Minor] Properly merge Redis hash into a table X-Git-Tag: 1.7.4~53^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3c69fb32830fb2f6b9b06ad7ab2fead99278afc1;p=thirdparty%2Frspamd.git [Minor] Properly merge Redis hash into a table --- diff --git a/src/plugins/lua/bayes_expiry.lua b/src/plugins/lua/bayes_expiry.lua index 5a67bd90a1..4f4d810bbf 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