diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mod_pep.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua index 5d51f196..afa3a38b 100644 --- a/plugins/mod_pep.lua +++ b/plugins/mod_pep.lua @@ -18,8 +18,20 @@ local lib_pubsub = module:require "pubsub"; local empty_set = set_new(); +-- username -> object passed to module:add_items() +local pep_service_items = {}; + +-- size of caches with full pubsub service objects +local service_cache_size = module:get_option_number("pep_service_cache_size", 1000); + -- username -> util.pubsub service object -local services = {}; +local services = cache.new(service_cache_size, function (username, _) + local item = pep_service_items[username]; + pep_service_items[username] = nil; + if item then + module:remove_item("pep-service", item); + end +end):table(); -- username -> recipient -> set of nodes local recipients = {}; @@ -202,7 +214,9 @@ function get_pep_service(username) check_node_config = check_node_config; }); services[username] = service; - module:add_item("pep-service", { service = service, jid = user_bare }); + local item = { service = service, jid = user_bare } + pep_service_items[username] = item; + module:add_item("pep-service", item); return service; end |