Changeset

10029:2c8f674b9243 0.11

mod_muc_mam: Cache last date that archive owner has messages to reduce writes (fixes #1368)
author Kim Alvefur <zash@zash.se>
date Mon, 27 May 2019 19:00:34 +0200
parents 10028:79ba2d709e72
children 10030:98ef41a60fc3 10036:045209b41b3a
files plugins/mod_muc_mam.lua
diffstat 1 files changed, 7 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_muc_mam.lua	Mon May 27 19:00:32 2019 +0200
+++ b/plugins/mod_muc_mam.lua	Mon May 27 19:00:34 2019 +0200
@@ -422,8 +422,14 @@
 	-- 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 ()