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

@@ -7,6 +7,7 @@ var plugins = require('../plugins');
var topics = require('../topics');
var groups = require('../groups');
var privileges = require('../privileges');
var cache = require('../cache');
module.exports = function (Categories) {
Categories.purge = function (cid, uid, callback) {
@@ -94,7 +95,18 @@ module.exports = function (Categories) {
], next);
}, next);
},
], next);
], function (err) {
if (err) {
return next(err);
}
cache.del([
'categories:cid',
'cid:0:children',
'cid:' + results.parentCid + ':children',
'cid:' + cid + ':children',
]);
next();
});
},
], function (err) {
callback(err);