first commit
This commit is contained in:
29
app/controllers/cache_status_controller.js
Normal file
29
app/controllers/cache_status_controller.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
var _ = require('underscore');
|
||||
|
||||
function CacheStatusController(tableCache) {
|
||||
this.tableCache = tableCache;
|
||||
}
|
||||
|
||||
CacheStatusController.prototype.route = function (app) {
|
||||
app.get(global.settings.base_url + '/cachestatus', this.handleCacheStatus.bind(this));
|
||||
};
|
||||
|
||||
CacheStatusController.prototype.handleCacheStatus = function (req, res) {
|
||||
var tableCacheValues = this.tableCache.values();
|
||||
var totalExplainKeys = tableCacheValues.length;
|
||||
var totalExplainHits = _.reduce(tableCacheValues, function(memo, res) {
|
||||
return memo + res.hits;
|
||||
}, 0);
|
||||
|
||||
res.send({
|
||||
explain: {
|
||||
pid: process.pid,
|
||||
hits: totalExplainHits,
|
||||
keys : totalExplainKeys
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = CacheStatusController;
|
||||
Reference in New Issue
Block a user