Skip to content

Commit

Permalink
[Feature] Maps: Allow caching for complex maps
Browse files Browse the repository at this point in the history
  • Loading branch information
vstakhov committed Aug 27, 2019
1 parent 0e83a53 commit 79e3360
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lualib/lua_maps.lua
Expand Up @@ -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 = {}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79e3360

Please sign in to comment.