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');
|
2022-08-14 02:35:59 +02:00
|
|
|
const plugins = require('../../plugins');
|
2021-09-24 19:58:10 -04:00
|
|
|
|
2020-11-07 22:06:25 -05:00
|
|
|
SocketCache.clear = async function (socket, data) {
|
2026-02-11 20:17:06 -05:00
|
|
|
const caches = await getAvailableCaches();
|
2022-08-14 02:35:59 +02:00
|
|
|
if (!caches[data.name]) {
|
|
|
|
|
return;
|
2020-11-07 22:06:25 -05:00
|
|
|
}
|
2022-08-14 02:35:59 +02:00
|
|
|
caches[data.name].reset();
|
2020-07-29 12:50:18 -04:00
|
|
|
};
|
2020-11-06 23:13:12 -05:00
|
|
|
|
|
|
|
|
SocketCache.toggle = async function (socket, data) {
|
2026-02-11 20:17:06 -05:00
|
|
|
const caches = await getAvailableCaches();
|
2020-11-06 23:13:12 -05:00
|
|
|
if (!caches[data.name]) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
caches[data.name].enabled = data.enabled;
|
|
|
|
|
};
|
2026-02-11 20:17:06 -05:00
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|