diff options
author | Kim Alvefur <zash@zash.se> | 2019-05-27 19:00:34 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2019-05-27 19:00:34 +0200 |
commit | e96902f6b477fe31d599ae9abf50e9baf0489d50 (patch) | |
tree | 67cd5a64c2517177dbc0dd9cb22202577b6465ad /plugins/mod_muc_mam.lua | |
parent | 837334916e773f4e69812057db281e0e2c549129 (diff) | |
download | prosody-e96902f6b477fe31d599ae9abf50e9baf0489d50.tar.gz prosody-e96902f6b477fe31d599ae9abf50e9baf0489d50.zip |
mod_muc_mam: Cache last date that archive owner has messages to reduce writes (fixes #1368)
Diffstat (limited to 'plugins/mod_muc_mam.lua')
-rw-r--r-- | plugins/mod_muc_mam.lua | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/plugins/mod_muc_mam.lua b/plugins/mod_muc_mam.lua index 1fbc8b2a..a2e3f81b 100644 --- a/plugins/mod_muc_mam.lua +++ b/plugins/mod_muc_mam.lua @@ -422,8 +422,14 @@ if cleanup_after ~= "never" then -- messages, we collect the union of sets of rooms from dates that fall -- outside the cleanup range. + local last_date = require "util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000)); function schedule_cleanup(roomname, date) - cleanup_map:set(date or datestamp(), roomname, true); + date = date or datestamp(); + if last_date:get(roomname) == date then return end + local ok = cleanup_map:set(date, roomname, true); + if ok then + last_date:set(roomname, date); + end end cleanup_runner = require "util.async".runner(function () |