mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: add hits/sec for cache
This commit is contained in:
@@ -39,6 +39,8 @@ get:
|
|||||||
type: number
|
type: number
|
||||||
hits:
|
hits:
|
||||||
type: string
|
type: string
|
||||||
|
hitsPerSecond:
|
||||||
|
type: number
|
||||||
misses:
|
misses:
|
||||||
type: string
|
type: string
|
||||||
hitRatio:
|
hitRatio:
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ cacheController.get = async function (req, res) {
|
|||||||
const groupCache = require('../../groups').cache;
|
const groupCache = require('../../groups').cache;
|
||||||
const { objectCache } = require('../../database');
|
const { objectCache } = require('../../database');
|
||||||
const localCache = require('../../cache');
|
const localCache = require('../../cache');
|
||||||
|
const uptimeInSeconds = process.uptime();
|
||||||
function getInfo(cache) {
|
function getInfo(cache) {
|
||||||
return {
|
return {
|
||||||
length: cache.length,
|
length: cache.length,
|
||||||
@@ -21,6 +21,7 @@ cacheController.get = async function (req, res) {
|
|||||||
((cache.length / cache.maxSize) * 100).toFixed(2) :
|
((cache.length / cache.maxSize) * 100).toFixed(2) :
|
||||||
((cache.itemCount / cache.max) * 100).toFixed(2),
|
((cache.itemCount / cache.max) * 100).toFixed(2),
|
||||||
hits: utils.addCommas(String(cache.hits)),
|
hits: utils.addCommas(String(cache.hits)),
|
||||||
|
hitsPerSecond: (cache.hits / uptimeInSeconds).toFixed(2),
|
||||||
misses: utils.addCommas(String(cache.misses)),
|
misses: utils.addCommas(String(cache.misses)),
|
||||||
hitRatio: ((cache.hits / (cache.hits + cache.misses) || 0)).toFixed(4),
|
hitRatio: ((cache.hits / (cache.hits + cache.misses) || 0)).toFixed(4),
|
||||||
enabled: cache.enabled,
|
enabled: cache.enabled,
|
||||||
|
|||||||
@@ -11,25 +11,28 @@
|
|||||||
<input class="form-check-input" type="checkbox" {{{if caches.enabled}}}checked{{{end}}}>
|
<input class="form-check-input" type="checkbox" {{{if caches.enabled}}}checked{{{end}}}>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3">{{{if ../length}}}{../length}{{{else}}}{../itemCount}{{{end}}} / {{{if ../max}}}{../max}{{{else}}}{../maxSize}{{{end}}}</div>
|
<div class="mb-3">{{{if ./length}}}{./length}{{{else}}}{./itemCount}{{{end}}} / {{{if ./max}}}{./max}{{{else}}}{./maxSize}{{{end}}}</div>
|
||||||
<div class="progress mb-3" style="height:20px;">
|
<div class="progress mb-3" style="height:20px;">
|
||||||
<div class="progress-bar" role="progressbar" aria-valuenow="{../percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {../percentFull}%;">
|
<div class="progress-bar" role="progressbar" aria-valuenow="{./percentFull}" aria-valuemin="0" aria-valuemax="100" style="width: {./percentFull}%;">
|
||||||
[[admin/advanced/cache:percent-full, {../percentFull}]]
|
[[admin/advanced/cache:percent-full, {./percentFull}]]
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label>Hits:</label> <span>{../hits}</span>
|
<label>Hits:</label> <span>{./hits}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label>Misses:</label> <span>{../misses}</span>
|
<label>Misses:</label> <span>{./misses}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label>Hit Ratio:</label> <span>{../hitRatio}</span>
|
<label>Hit Ratio:</label> <span>{./hitRatio}</span>
|
||||||
|
</div>
|
||||||
|
<div class="mb-2">
|
||||||
|
<label>Hits / Sec:</label> <span>{./hitsPerSecond}</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{{if ../ttl}}}
|
{{{if ./ttl}}}
|
||||||
<div class="mb-2">
|
<div class="mb-2">
|
||||||
<label>TTL:</label> <span>{../ttl}</span>
|
<label>TTL:</label> <span>{./ttl}</span>
|
||||||
</div>
|
</div>
|
||||||
{{{end}}}
|
{{{end}}}
|
||||||
{{{if (@key == "post")}}}
|
{{{if (@key == "post")}}}
|
||||||
|
|||||||
Reference in New Issue
Block a user