feat: add hits/sec for cache

This commit is contained in:
Barış Soner Uşaklı
2023-04-22 16:41:27 -04:00
parent 9894d05f32
commit 94f2e50883
3 changed files with 15 additions and 9 deletions

View File

@@ -10,7 +10,7 @@ cacheController.get = async function (req, res) {
const groupCache = require('../../groups').cache;
const { objectCache } = require('../../database');
const localCache = require('../../cache');
const uptimeInSeconds = process.uptime();
function getInfo(cache) {
return {
length: cache.length,
@@ -21,6 +21,7 @@ cacheController.get = async function (req, res) {
((cache.length / cache.maxSize) * 100).toFixed(2) :
((cache.itemCount / cache.max) * 100).toFixed(2),
hits: utils.addCommas(String(cache.hits)),
hitsPerSecond: (cache.hits / uptimeInSeconds).toFixed(2),
misses: utils.addCommas(String(cache.misses)),
hitRatio: ((cache.hits / (cache.hits + cache.misses) || 0)).toFixed(4),
enabled: cache.enabled,