equal
deleted
inserted
replaced
420 |
420 |
421 -- For each day, store a set of rooms that have new messages. To expire |
421 -- For each day, store a set of rooms that have new messages. To expire |
422 -- messages, we collect the union of sets of rooms from dates that fall |
422 -- messages, we collect the union of sets of rooms from dates that fall |
423 -- outside the cleanup range. |
423 -- outside the cleanup range. |
424 |
424 |
|
425 local last_date = require "util.cache".new(module:get_option_number("muc_log_cleanup_date_cache_size", 1000)); |
425 function schedule_cleanup(roomname, date) |
426 function schedule_cleanup(roomname, date) |
426 cleanup_map:set(date or datestamp(), roomname, true); |
427 date = date or datestamp(); |
|
428 if last_date:get(roomname) == date then return end |
|
429 local ok = cleanup_map:set(date, roomname, true); |
|
430 if ok then |
|
431 last_date:set(roomname, date); |
|
432 end |
427 end |
433 end |
428 |
434 |
429 cleanup_runner = require "util.async".runner(function () |
435 cleanup_runner = require "util.async".runner(function () |
430 local rooms = {}; |
436 local rooms = {}; |
431 local cut_off = datestamp(os.time() - cleanup_after); |
437 local cut_off = datestamp(os.time() - cleanup_after); |