aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_mam/mod_mam.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-05-27 19:00:32 +0200
committerKim Alvefur <zash@zash.se>2019-05-27 19:00:32 +0200
commitfddbd6ed134ebde535c574da5e8a7a0d4e007767 (patch)
treedb3205f9d2ddf06d44510b7457c3047887e7df8c /plugins/mod_mam/mod_mam.lua
parentcdd8ba5308e3d987fdd66559da734ab4cb8a169f (diff)
downloadprosody-fddbd6ed134ebde535c574da5e8a7a0d4e007767.tar.gz
prosody-fddbd6ed134ebde535c574da5e8a7a0d4e007767.zip
mod_mam: Cache last date that archive owner has messages to reduce writes (fixes #1368)
Diffstat (limited to 'plugins/mod_mam/mod_mam.lua')
-rw-r--r--plugins/mod_mam/mod_mam.lua8
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_mam/mod_mam.lua b/plugins/mod_mam/mod_mam.lua
index a8c2689d..8900a2be 100644
--- a/plugins/mod_mam/mod_mam.lua
+++ b/plugins/mod_mam/mod_mam.lua
@@ -348,8 +348,14 @@ if cleanup_after ~= "never" then
-- messages, we collect the union of sets of users from dates that fall
-- outside the cleanup range.
+ local last_date = require "util.cache".new(module:get_option_number("archive_cleanup_date_cache_size", 1000));
function schedule_cleanup(username, date)
- cleanup_map:set(date or datestamp(), username, true);
+ date = date or datestamp();
+ if last_date:get(username) == date then return end
+ local ok = cleanup_map:set(date, username, true);
+ if ok then
+ last_date:set(username, date);
+ end
end
cleanup_runner = require "util.async".runner(function ()