summaryrefslogtreecommitdiffstats
path: root/lualib/lua_maps.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-27 19:20:51 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-08-27 19:20:51 +0100
commit79e3360f4d091ebbc53e944cf882029156469383 (patch)
treeb16b756f4fd10edb167b9fbb24293044cc004e08 /lualib/lua_maps.lua
parent0e83a5325c17e77542b209ea7773e1129e87864b (diff)
downloadrspamd-79e3360f4d091ebbc53e944cf882029156469383.tar.gz
rspamd-79e3360f4d091ebbc53e944cf882029156469383.zip
[Feature] Maps: Allow caching for complex maps
Diffstat (limited to 'lualib/lua_maps.lua')
-rw-r--r--lualib/lua_maps.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/lualib/lua_maps.lua b/lualib/lua_maps.lua
index 094494dca..23e5cb942 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