Files
NodeBB/src/socket.io/admin/cache.js
Barış Soner Uşaklı 7336c58cdf refactor: cache page to table
display notif cache too
2026-02-11 20:17:06 -05:00

33 lines
824 B
JavaScript

'use strict';
const SocketCache = module.exports;
const db = require('../../database');
const plugins = require('../../plugins');
SocketCache.clear = async function (socket, data) {
const caches = await getAvailableCaches();
if (!caches[data.name]) {
return;
}
caches[data.name].reset();
};
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);
}