From: Vsevolod Stakhov Date: Tue, 27 Aug 2019 18:20:51 +0000 (+0100) Subject: [Feature] Maps: Allow caching for complex maps X-Git-Tag: 2.0~328 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79e3360f4d091ebbc53e944cf882029156469383;p=thirdparty%2Frspamd.git [Feature] Maps: Allow caching for complex maps --- diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua index 094494dcab..23e5cb942d 100644 --- a/lualib/lua_maps.lua +++ b/lualib/lua_maps.lua @@ -21,6 +21,7 @@ limitations under the License. local rspamd_logger = require "rspamd_logger" local ts = require("tableshape").types +local lua_util = require "lua_util" local exports = {} @@ -137,8 +138,14 @@ local function rspamd_map_add_from_ucl(opt, mtype, description) return ret end elseif type(opt) == 'table' then - -- it might be plain map or map of plain elements - -- no caching in this case (yet) + local k = lua_util.table_digest(opt) + if maps_cache[k] then + rspamd_logger.infox(rspamd_config, 'reuse url for %s(%s)', + opt, mtype) + + return maps_cache[k] + end + if opt[1] then if mtype == 'radix' then