Show general last invalidation message

This commit is contained in:
Ajay 2024-02-08 21:15:28 -05:00
parent f3fffa56c9
commit 9364a7e654

View file

@ -20,6 +20,7 @@ export interface RedisStats {
memoryCacheLength: number; memoryCacheLength: number;
memoryCacheSize: number; memoryCacheSize: number;
lastInvalidation: number; lastInvalidation: number;
lastInvalidationMessage: number;
} }
interface RedisSB { interface RedisSB {
@ -58,6 +59,7 @@ let writeRequests = 0;
let memoryCacheHits = 0; let memoryCacheHits = 0;
let memoryCacheMisses = 0; let memoryCacheMisses = 0;
let memoryCacheUncachedMisses = 0; let memoryCacheUncachedMisses = 0;
let lastInvalidationMessage = 0;
let lastInvalidation = 0; let lastInvalidation = 0;
const readResponseTime: number[] = []; const readResponseTime: number[] = [];
@ -296,7 +298,8 @@ export function getRedisStats(): RedisStats {
memoryCacheTotalHits: memoryCacheHits / (memoryCacheHits + memoryCacheMisses + memoryCacheUncachedMisses), memoryCacheTotalHits: memoryCacheHits / (memoryCacheHits + memoryCacheMisses + memoryCacheUncachedMisses),
memoryCacheLength: cache?.size ?? 0, memoryCacheLength: cache?.size ?? 0,
memoryCacheSize: cache?.calculatedSize ?? 0, memoryCacheSize: cache?.calculatedSize ?? 0,
lastInvalidation lastInvalidation,
lastInvalidationMessage
}; };
} }
@ -306,6 +309,7 @@ async function setupCacheClientListener(cacheClient: RedisClientType,
cacheConnectionClientId = String(await cacheClient.clientId()); cacheConnectionClientId = String(await cacheClient.clientId());
cacheClient.subscribe("__redis__:invalidate", (messages) => { cacheClient.subscribe("__redis__:invalidate", (messages) => {
lastInvalidationMessage = Date.now();
if (cache.delete(messages?.[0])) { if (cache.delete(messages?.[0])) {
lastInvalidation = Date.now(); lastInvalidation = Date.now();
} }