Skip to content

Node.js based forum software built for the modern web

fix: #8789,cache meta.settings

Barış Soner Uşaklı156e1396f238
diff --git a/src/meta/settings.js b/src/meta/settings.js
index 8d4d4a6863..76db1d41aa 100644
--- a/src/meta/settings.js
+++ b/src/meta/settings.js
@@ -4,10 +4,15 @@ const db = require('../database');
const plugins = require('../plugins');
const Meta = require('./index');
const pubsub = require('../pubsub');
+const cache = require('../cache');
const Settings = module.exports;
Settings.get = async function (hash) {
+ const cached = cache.get('settings:' + hash);
+ if (cached) {
+ return cached;
+ }
let data = await db.getObject('settings:' + hash) || {};
const sortedLists = await db.getSetMembers('settings:' + hash + ':sorted-lists');
@@ -27,6 +32,7 @@ Settings.get = async function (hash) {
}));
({ values: data } = await plugins.fireHook('filter:settings.get', { plugin: hash, values: data }));
+ cache.set('settings:' + hash, data);
return data;
};
@@ -86,6 +92,7 @@ Settings.set = async function (hash, values, quiet) {
pubsub.publish('action:settings.set.' + hash, values);
Meta.reloadRequired = !quiet;
+ cache.del('settings:' + hash);
};
Settings.setOne = async function (hash, field, value) {