fix(Caching): sweep archived threads in all channel caches (#6312)

This commit is contained in:
ckohen
2021-08-06 05:54:19 -07:00
committed by GitHub
parent a0974fdbbb
commit 3725dcafc0
6 changed files with 37 additions and 7 deletions

View File

@@ -635,6 +635,21 @@ class Util extends null {
setTimeout(resolve, ms);
});
}
/**
* Creates a sweep filter that sweeps archived threads
* @param {number} [lifetime=14400] How long a thread has to be archived to be valid for sweeping
* @returns {SweepFilter}
*/
static archivedThreadSweepFilter(lifetime = 14400) {
const filter = require('./LimitedCollection').filterByLifetime({
lifetime,
getComparisonTimestamp: e => e.archiveTimestamp,
excludeFromSweep: e => !e.archived,
});
filter.isDefault = true;
return filter;
}
}
module.exports = Util;