mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-06 12:31:33 +01:00
cache categories:cid and cid:<cid>:children
these rarely change, no need to go to db for them
This commit is contained in:
@@ -8,6 +8,7 @@ cacheController.get = function (req, res) {
|
||||
var postCache = require('../../posts/cache');
|
||||
var groupCache = require('../../groups').cache;
|
||||
var objectCache = require('../../database').objectCache;
|
||||
var localCache = require('../../cache');
|
||||
|
||||
var avgPostSize = 0;
|
||||
var percentFull = 0;
|
||||
@@ -32,11 +33,20 @@ cacheController.get = function (req, res) {
|
||||
max: groupCache.max,
|
||||
itemCount: groupCache.itemCount,
|
||||
percentFull: ((groupCache.length / groupCache.max) * 100).toFixed(2),
|
||||
dump: req.query.debug ? JSON.stringify(groupCache.dump(), null, 4) : false,
|
||||
hits: utils.addCommas(String(groupCache.hits)),
|
||||
misses: utils.addCommas(String(groupCache.misses)),
|
||||
hitRatio: (groupCache.hits / (groupCache.hits + groupCache.misses)).toFixed(4),
|
||||
},
|
||||
localCache: {
|
||||
length: localCache.length,
|
||||
max: localCache.max,
|
||||
itemCount: localCache.itemCount,
|
||||
percentFull: ((localCache.length / localCache.max) * 100).toFixed(2),
|
||||
dump: req.query.debug ? JSON.stringify(localCache.dump(), null, 4) : false,
|
||||
hits: utils.addCommas(String(localCache.hits)),
|
||||
misses: utils.addCommas(String(localCache.misses)),
|
||||
hitRatio: (localCache.hits / (localCache.hits + localCache.misses)).toFixed(4),
|
||||
},
|
||||
};
|
||||
|
||||
if (objectCache) {
|
||||
@@ -45,7 +55,6 @@ cacheController.get = function (req, res) {
|
||||
max: objectCache.max,
|
||||
itemCount: objectCache.itemCount,
|
||||
percentFull: ((objectCache.length / objectCache.max) * 100).toFixed(2),
|
||||
dump: req.query.debug ? JSON.stringify(objectCache.dump(), null, 4) : false,
|
||||
hits: utils.addCommas(String(objectCache.hits)),
|
||||
misses: utils.addCommas(String(objectCache.misses)),
|
||||
hitRatio: (objectCache.hits / (objectCache.hits + objectCache.misses)).toFixed(4),
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var db = require('../../database');
|
||||
var categories = require('../../categories');
|
||||
var privileges = require('../../privileges');
|
||||
var plugins = require('../../plugins');
|
||||
@@ -12,7 +11,7 @@ var homePageController = module.exports;
|
||||
homePageController.get = function (req, res, next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, next);
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
},
|
||||
function (cids, next) {
|
||||
privileges.categories.filterCids('find', cids, 0, next);
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
var async = require('async');
|
||||
|
||||
var db = require('../../database');
|
||||
var categories = require('../../categories');
|
||||
var privileges = require('../../privileges');
|
||||
|
||||
@@ -23,7 +22,7 @@ privilegesController.get = function (req, res, callback) {
|
||||
allCategories: function (next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRange('categories:cid', 0, -1, next);
|
||||
categories.getAllCidsFromSet('categories:cid', next);
|
||||
},
|
||||
function (cids, next) {
|
||||
categories.getCategories(cids, req.uid, next);
|
||||
|
||||
Reference in New Issue
Block a user