Software /
code /
prosody
Comparison
plugins/mod_blocklist.lua @ 6970:cde7d14052f9
mod_blocklist: Expand comments on caching of blocklists
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 06 Dec 2015 02:09:52 +0100 |
parent | 6969:31d8e1a8a014 |
child | 6971:96080d86bab8 |
comparison
equal
deleted
inserted
replaced
6969:31d8e1a8a014 | 6970:cde7d14052f9 |
---|---|
17 local jid_split = require"util.jid".split; | 17 local jid_split = require"util.jid".split; |
18 | 18 |
19 local storage = module:open_store(); | 19 local storage = module:open_store(); |
20 local sessions = prosody.hosts[module.host].sessions; | 20 local sessions = prosody.hosts[module.host].sessions; |
21 | 21 |
22 -- Cache of blocklists by username may randomly expire at any time | 22 -- First level cache of blocklists by username. |
23 -- Weak table so may randomly expire at any time. | |
23 local cache = setmetatable({}, { __mode = "v" }); | 24 local cache = setmetatable({}, { __mode = "v" }); |
24 | 25 |
25 -- Second level of caching, keeps a fixed number of items, | 26 -- Second level of caching, keeps a fixed number of items, also anchors |
26 -- also anchors items in the above cache | 27 -- items in the above cache. |
28 -- | |
29 -- The size of this affects how often we will need to load a blocklist from | |
30 -- disk, which we want to avoid during routing. On the other hand, we don't | |
31 -- want to use too much memory either, so this can be tuned by advanced | |
32 -- users. TODO use science to figure out a better default, 64 is just a guess. | |
27 local cache_size = module:get_option_number("blocklist_cache_size", 64); | 33 local cache_size = module:get_option_number("blocklist_cache_size", 64); |
28 local cache2 = require"util.cache".new(cache_size); | 34 local cache2 = require"util.cache".new(cache_size); |
29 | 35 |
30 local null_blocklist = {}; | 36 local null_blocklist = {}; |
31 | 37 |