Mercurial > prosody-modules
diff mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua @ 5805:55b99f593c3a
mod_pubsub_serverinfo: Disco/info cache TTL should be configurable
This module caches the disco/info results of remote domains. This commit introduces a new configuration option that allows an admin to configure the cache expiry duration.
author | Guus der Kinderen <guus.der.kinderen@gmail.com> |
---|---|
date | Thu, 04 Jan 2024 12:05:51 +0100 |
parents | c3eeeb968403 |
children | 2465d5191ae9 |
line wrap: on
line diff
--- a/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Thu Jan 04 11:59:35 2024 +0100 +++ b/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Thu Jan 04 12:05:51 2024 +0100 @@ -7,6 +7,7 @@ local node = module:get_option(module.name .. "_node") or "serverinfo"; local actor = module.host .. "/modules/" .. module.name; local publication_interval = module:get_option(module.name .. "_publication_interval") or 300; +local cache_ttl = module:get_option(module.name .. "_cache_ttl") or 3600; local opt_in_reports @@ -213,7 +214,7 @@ if feature.attr.var == 'urn:xmpp:serverinfo:0' then opt_in_cache[remoteDomain] = { opt_in = true; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } return; -- prevent 'false' to be cached, down below. end @@ -222,13 +223,13 @@ end opt_in_cache[remoteDomain] = { opt_in = false; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } end, function(response) opt_in_cache[remoteDomain] = { opt_in = false; - expires = os.time() + 3600; + expires = os.time() + cache_ttl; } end );