plugins/mod_muc_mam.lua
changeset 10034 98ef41a60fc3
parent 10026 b56654f89cd5
parent 10033 2c8f674b9243
child 10115 0f335815244f
--- a/plugins/mod_muc_mam.lua	Mon May 27 12:14:05 2019 +0200
+++ b/plugins/mod_muc_mam.lua	Mon May 27 19:17:12 2019 +0200
@@ -458,8 +458,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 ()