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

33 lines
824 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');
const plugins = require('../../plugins');
2021-09-24 19:58:10 -04:00
SocketCache.clear = async function (socket, data) {
const caches = await getAvailableCaches();
if (!caches[data.name]) {
return;
}
caches[data.name].reset();
2020-07-29 12:50:18 -04:00
};
SocketCache.toggle = async function (socket, data) {
const caches = await getAvailableCaches();
if (!caches[data.name]) {
return;
}
caches[data.name].enabled = data.enabled;
};
async function getAvailableCaches() {
const caches = {
post: require('../../posts/cache').getOrCreate(),
object: db.objectCache,
group: require('../../groups').cache,
local: require('../../cache'),
notification: require('../../notifications').delayCache,
};
return await plugins.hooks.fire('filter:admin.cache.get', caches);
}