2018-10-15 13:45:55 -04:00
|
|
|
'use strict';
|
|
|
|
|
|
2022-08-10 15:26:07 -04:00
|
|
|
const cacheCreate = require('../cache/lru');
|
2018-10-15 13:45:55 -04:00
|
|
|
|
|
|
|
|
module.exports = function (Groups) {
|
2020-11-06 23:13:12 -05:00
|
|
|
Groups.cache = cacheCreate({
|
|
|
|
|
name: 'group',
|
|
|
|
|
max: 40000,
|
2022-08-10 13:24:16 -04:00
|
|
|
ttl: 0,
|
2018-10-15 13:45:55 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
Groups.clearCache = function (uid, groupNames) {
|
|
|
|
|
if (!Array.isArray(groupNames)) {
|
|
|
|
|
groupNames = [groupNames];
|
|
|
|
|
}
|
2021-02-03 23:59:08 -07:00
|
|
|
const keys = groupNames.map(name => `${uid}:${name}`);
|
2020-11-06 23:13:12 -05:00
|
|
|
Groups.cache.del(keys);
|
2018-10-15 13:45:55 -04:00
|
|
|
};
|
|
|
|
|
};
|