Node.js based forum software built for the modern web
add cache hits/misses to posts cache
Barış Soner Uşaklı6c15aee888fb
diff --git a/src/controllers/admin/cache.js b/src/controllers/admin/cache.jsindex c8f870559d..51c4fbb51b 100644--- a/src/controllers/admin/cache.js+++ b/src/controllers/admin/cache.js@@ -23,6 +23,9 @@ cacheController.get = function (req, res) {itemCount: postCache.itemCount,percentFull: percentFull,avgPostSize: avgPostSize,+ 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,diff --git a/src/posts/cache.js b/src/posts/cache.jsindex 28c58839e8..9c9bbe67d5 100644--- a/src/posts/cache.js+++ b/src/posts/cache.js@@ -8,5 +8,7 @@ var cache = LRU({length: function (n) { return n.length; },maxAge: 0,});+cache.hits = 0;+cache.misses = 0;module.exports = cache;diff --git a/src/posts/parse.js b/src/posts/parse.jsindex d6f7165f19..da293d0db8 100644--- a/src/posts/parse.js+++ b/src/posts/parse.js@@ -27,8 +27,10 @@ module.exports = function (Posts) {if (postData.pid && cache.has(String(postData.pid))) {postData.content = cache.get(String(postData.pid));+ cache.hits += 1;return callback(null, postData);}+ cache.misses += 1;async.waterfall([function (next) {diff --git a/src/views/admin/advanced/cache.tpl b/src/views/admin/advanced/cache.tplindex 302feb07f2..9e7c008ffc 100644--- a/src/views/admin/advanced/cache.tpl+++ b/src/views/admin/advanced/cache.tpl@@ -19,6 +19,11 @@[[admin/advanced/cache:percent-full, {postCache.percentFull}]]</div></div>++ <label>Hits:</label> <span>{postCache.hits}</span><br/>+ <label>Misses:</label> <span>{postCache.misses}</span><br/>+ <label>Hit Ratio:</label> <span>{postCache.hitRatio}</span><br/>+<div class="form-group"><label for="postCacheSize">[[admin/advanced/cache:post-cache-size]]</label><input id="postCacheSize" type="text" class="form-control" value="" data-field="postCacheSize">