Changeset

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
parents 6969:31d8e1a8a014
children 6971:96080d86bab8
files plugins/mod_blocklist.lua
diffstat 1 files changed, 9 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_blocklist.lua	Sun Dec 06 02:08:24 2015 +0100
+++ b/plugins/mod_blocklist.lua	Sun Dec 06 02:09:52 2015 +0100
@@ -19,11 +19,17 @@
 local storage = module:open_store();
 local sessions = prosody.hosts[module.host].sessions;
 
--- Cache of blocklists by username may randomly expire at any time
+-- First level cache of blocklists by username.
+-- Weak table so may randomly expire at any time.
 local cache = setmetatable({}, { __mode = "v" });
 
--- Second level of caching, keeps a fixed number of items,
--- also anchors items in the above cache
+-- Second level of caching, keeps a fixed number of items, also anchors
+-- items in the above cache.
+--
+-- The size of this affects how often we will need to load a blocklist from
+-- disk, which we want to avoid during routing. On the other hand, we don't
+-- want to use too much memory either, so this can be tuned by advanced
+-- users. TODO use science to figure out a better default, 64 is just a guess.
 local cache_size = module:get_option_number("blocklist_cache_size", 64);
 local cache2 = require"util.cache".new(cache_size);