diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-10 17:42:32 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2017-02-10 18:03:35 +0000 |
commit | 98b4d5370a2cd8e26de677151d7f335c4eae7e77 (patch) | |
tree | 57451633f19b51e880ce37e20a56fe4837c3b21b /rules | |
parent | c7367cc48e9b63bd6c71fbbcdedacac6930bab3b (diff) | |
download | rspamd-98b4d5370a2cd8e26de677151d7f335c4eae7e77.tar.gz rspamd-98b4d5370a2cd8e26de677151d7f335c4eae7e77.zip |
[Minor] Store metatokens in task cache
Diffstat (limited to 'rules')
-rw-r--r-- | rules/global_functions.lua | 16 |
1 files changed, 12 insertions, 4 deletions
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 |