diff options
Diffstat (limited to 'src/plugins/lua/bayes_expiry.lua')
-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 |