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

43 lines
1.2 KiB
JavaScript
Raw Normal View History

'use strict';
var cacheController = {};
2017-02-18 15:05:36 -07:00
cacheController.get = function (req, res) {
var postCache = require('../../posts/cache');
var groupCache = require('../../groups').cache;
2017-05-03 16:36:34 -04:00
var userSettingsCache = require('../../user').settingsCache;
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);
}
res.render('admin/advanced/cache', {
postCache: {
length: postCache.length,
max: postCache.max,
itemCount: postCache.itemCount,
percentFull: percentFull,
2017-02-17 19:31:21 -07:00
avgPostSize: avgPostSize,
},
2017-05-03 16:36:34 -04:00
userSettingsCache: {
length: userSettingsCache.length,
max: userSettingsCache.max,
itemCount: userSettingsCache.itemCount,
percentFull: ((userSettingsCache.length / userSettingsCache.max) * 100).toFixed(2),
},
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,
},
});
};
2017-02-18 02:30:48 -07:00
module.exports = cacheController;