From: Vsevolod Stakhov Date: Fri, 10 Feb 2017 17:42:32 +0000 (+0000) Subject: [Minor] Store metatokens in task cache X-Git-Tag: 1.5.0~135 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=98b4d5370a2cd8e26de677151d7f335c4eae7e77;p=rspamd.git [Minor] Store metatokens in task cache --- diff --git a/rules/global_functions.lua b/rules/global_functions.lua index 750516190..f878a8c9e 100644 --- a/rules/global_functions.lua +++ b/rules/global_functions.lua @@ -366,12 +366,20 @@ local metafunctions = { function rspamd_gen_metatokens(task) local ipairs = ipairs local metatokens = {} - for _,mt in ipairs(metafunctions) do - local ct = mt.cb(task) + local cached = task:cache_get('metatokens') + + if cached then + return cached + else + for _,mt in ipairs(metafunctions) do + local ct = mt.cb(task) - for _,tok in ipairs(ct) do - table.insert(metatokens, tok) + for _,tok in ipairs(ct) do + table.insert(metatokens, tok) + end end + + task:cache_set('metatokens', metatokens) end return metatokens