Files
NodeBB/src/controllers/admin/cache.js

57 lines
1.8 KiB
JavaScript
Raw Normal View History

'use strict';
2017-06-22 19:03:49 -04:00
var cacheController = module.exports;
2017-10-25 18:20:44 -04:00
var utils = require('../../utils');
2017-02-18 15:05:36 -07:00
cacheController.get = function (req, res) {
var postCache = require('../../posts/cache');
var groupCache = require('../../groups').cache;
var objectCache = require('../../database').objectCache;
var avgPostSize = 0;
var percentFull = 0;
if (postCache.itemCount > 0) {
avgPostSize = parseInt((postCache.length / postCache.itemCount), 10);
percentFull = ((postCache.length / postCache.max) * 100).toFixed(2);
}
var data = {
postCache: {
length: postCache.length,
max: postCache.max,
itemCount: postCache.itemCount,
percentFull: percentFull,
2017-02-17 19:31:21 -07:00
avgPostSize: avgPostSize,
2018-10-15 15:03:06 -04:00
hits: utils.addCommas(String(postCache.hits)),
misses: utils.addCommas(String(postCache.misses)),
hitRatio: ((postCache.hits / (postCache.hits + postCache.misses) || 0)).toFixed(4),
},
groupCache: {
length: groupCache.length,
max: groupCache.max,
itemCount: groupCache.itemCount,
percentFull: ((groupCache.length / groupCache.max) * 100).toFixed(2),
2017-02-17 19:31:21 -07:00
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),
2017-02-17 19:31:21 -07:00
},
};
if (objectCache) {
data.objectCache = {
length: objectCache.length,
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,
2017-10-25 18:20:44 -04:00
hits: utils.addCommas(String(objectCache.hits)),
misses: utils.addCommas(String(objectCache.misses)),
2017-12-14 14:18:56 -05:00
hitRatio: (objectCache.hits / (objectCache.hits + objectCache.misses)).toFixed(4),
};
}
res.render('admin/advanced/cache', data);
};