@ooples/token-optimizer-mcp
Version:
Intelligent context window optimization for Claude Code - store content externally via caching and compression, freeing up your context window for what matters
33 lines • 1.03 kB
JavaScript
/**
* Shared cache metrics utilities
*
* This module provides common calculation functions for cache statistics
* to prevent code duplication across the codebase.
*/
/**
* Calculate cache hit rate as a percentage
* @param cacheHits Number of cache hits
* @param cacheMisses Number of cache misses
* @returns Hit rate as a percentage (0-100), or 0 if no cache operations
*/
export function calculateCacheHitRate(cacheHits, cacheMisses) {
const total = cacheHits + cacheMisses;
if (total === 0) {
return 0;
}
return (cacheHits / total) * 100;
}
/**
* Calculate cache miss rate as a percentage
* @param cacheHits Number of cache hits
* @param cacheMisses Number of cache misses
* @returns Miss rate as a percentage (0-100), or 0 if no cache operations
*/
export function calculateCacheMissRate(cacheHits, cacheMisses) {
const total = cacheHits + cacheMisses;
if (total === 0) {
return 0;
}
return (cacheMisses / total) * 100;
}
//# sourceMappingURL=cache-metrics.js.map