Skip to content

Commit

Permalink
fix: #8789,cache meta.settings
Browse files Browse the repository at this point in the history
  • Loading branch information
barisusakli committed Oct 23, 2020
1 parent 7a31835 commit 156e139
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/meta/settings.js
Expand Up @@ -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');

Expand All @@ -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;
};

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 156e139

Please sign in to comment.