cache categories:cid and cid:<cid>:children

these rarely change, no need to go to db for them
This commit is contained in:
Barış Soner Uşaklı
2018-11-27 19:38:28 -05:00
parent 7357926fe7
commit 00a066985a
15 changed files with 168 additions and 43 deletions

View File

@@ -1,4 +1,3 @@
'use strict';
var async = require('async');
@@ -8,6 +7,7 @@ var meta = require('../meta');
var utils = require('../utils');
var translator = require('../translator');
var plugins = require('../plugins');
var cache = require('../cache');
module.exports = function (Categories) {
Categories.update = function (modified, callback) {
@@ -112,6 +112,10 @@ module.exports = function (Categories) {
function (next) {
db.setObjectField('category:' + cid, 'parentCid', newParent, next);
},
function (next) {
cache.del(['cid:' + oldParent + ':children', 'cid:' + newParent + ':children']);
next();
},
], next);
},
], function (err) {
@@ -149,6 +153,10 @@ module.exports = function (Categories) {
function (next) {
db.sortedSetAdd('cid:' + parentCid + ':children', order, cid, next);
},
function (next) {
cache.del(['categories:cid', 'cid:' + parentCid + ':children']);
next();
},
], next);
},
], function (err) {