Files
NodeBB/src/socket.io/admin/cache.js

31 lines
748 B
JavaScript
Raw Normal View History

2020-07-29 12:50:18 -04:00
'use strict';
const SocketCache = module.exports;
2021-09-24 19:58:10 -04:00
const db = require('../../database');
SocketCache.clear = async function (socket, data) {
if (data.name === 'post') {
require('../../posts/cache').reset();
2021-09-24 19:58:10 -04:00
} else if (data.name === 'object' && db.objectCache) {
db.objectCache.reset();
} else if (data.name === 'group') {
require('../../groups').cache.reset();
} else if (data.name === 'local') {
require('../../cache').reset();
}
2020-07-29 12:50:18 -04:00
};
SocketCache.toggle = async function (socket, data) {
const caches = {
post: require('../../posts/cache'),
2021-09-24 19:58:10 -04:00
object: db.objectCache,
group: require('../../groups').cache,
local: require('../../cache'),
};
if (!caches[data.name]) {
return;
}
caches[data.name].enabled = data.enabled;
};