mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-03-18 02:20:49 +01:00
cache group membership methods
groups.isMember groups.isMembers groups.isMemberOfGroups clear cache for user on group.join & group.leave
This commit is contained in:
36
src/controllers/admin/cache.js
Normal file
36
src/controllers/admin/cache.js
Normal file
@@ -0,0 +1,36 @@
|
||||
'use strict';
|
||||
|
||||
var cacheController = {};
|
||||
|
||||
cacheController.get = function(req, res, next) {
|
||||
var postCache = require('../../posts/cache');
|
||||
var groupCache = require('../../groups').cache;
|
||||
|
||||
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,
|
||||
avgPostSize: avgPostSize,
|
||||
dump: req.query.debug ? postCache.dump() : undefined
|
||||
},
|
||||
groupCache: {
|
||||
length: groupCache.length,
|
||||
max: groupCache.max,
|
||||
itemCount: groupCache.itemCount,
|
||||
percentFull: ((groupCache.length / groupCache.max) * 100).toFixed(2),
|
||||
dump: req.query.debug ? groupCache.dump() : undefined
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = cacheController;
|
||||
@@ -1,26 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var postCacheController = {};
|
||||
|
||||
postCacheController.get = function(req, res, next) {
|
||||
var cache = require('../../posts/cache');
|
||||
var avgPostSize = 0;
|
||||
var percentFull = 0;
|
||||
if (cache.itemCount > 0) {
|
||||
avgPostSize = parseInt((cache.length / cache.itemCount), 10);
|
||||
percentFull = ((cache.length / cache.max) * 100).toFixed(2);
|
||||
}
|
||||
|
||||
res.render('admin/advanced/post-cache', {
|
||||
cache: {
|
||||
length: cache.length,
|
||||
max: cache.max,
|
||||
itemCount: cache.itemCount,
|
||||
percentFull: percentFull,
|
||||
avgPostSize: avgPostSize
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
module.exports = postCacheController;
|
||||
Reference in New Issue
Block a user