mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-28 11:20:26 +01:00
* refactor: move src/cacheCreate.js to src/cache/lru.js * fix: call new library location for lru cache creator * feat: add ttl cache * fix: update upload throttler to use ttl cache instead of lru cache * chore: add missing dependency * fix: avoid pubsub conflicts * fix: use get instead of peek, which is not available in ttl-cache
20 lines
385 B
JavaScript
20 lines
385 B
JavaScript
'use strict';
|
|
|
|
const cacheCreate = require('../cache/lru');
|
|
|
|
module.exports = function (Groups) {
|
|
Groups.cache = cacheCreate({
|
|
name: 'group',
|
|
max: 40000,
|
|
ttl: 0,
|
|
});
|
|
|
|
Groups.clearCache = function (uid, groupNames) {
|
|
if (!Array.isArray(groupNames)) {
|
|
groupNames = [groupNames];
|
|
}
|
|
const keys = groupNames.map(name => `${uid}:${name}`);
|
|
Groups.cache.del(keys);
|
|
};
|
|
};
|