mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-24 08:19:48 +01:00
31 lines
748 B
JavaScript
31 lines
748 B
JavaScript
'use strict';
|
|
|
|
const SocketCache = module.exports;
|
|
|
|
const db = require('../../database');
|
|
|
|
SocketCache.clear = async function (socket, data) {
|
|
if (data.name === 'post') {
|
|
require('../../posts/cache').reset();
|
|
} 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();
|
|
}
|
|
};
|
|
|
|
SocketCache.toggle = async function (socket, data) {
|
|
const caches = {
|
|
post: require('../../posts/cache'),
|
|
object: db.objectCache,
|
|
group: require('../../groups').cache,
|
|
local: require('../../cache'),
|
|
};
|
|
if (!caches[data.name]) {
|
|
return;
|
|
}
|
|
caches[data.name].enabled = data.enabled;
|
|
};
|