MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / get_health_score

Method get_health_score

graphlite/src/cache/cache_manager.rs:597–633  ·  view source on GitHub ↗

Get cache health score (0.0 to 1.0)

(&self)

Source from the content-addressed store, hash-verified

595
596 /// Get cache health score (0.0 to 1.0)
597 pub fn get_health_score(&self) -> CacheHealthScore {
598 let stats = self.get_stats();
599
600 // Hit rate score (0.0 to 1.0)
601 let hit_rate_score = stats.global.overall_hit_rate();
602
603 // Memory efficiency score
604 let memory_usage_ratio =
605 stats.global.total_memory_bytes as f64 / self.config.max_memory_bytes as f64;
606 let memory_score = if memory_usage_ratio > 0.9 {
607 0.5 // High memory usage is concerning
608 } else if memory_usage_ratio > 0.7 {
609 0.8 // Moderate usage is good
610 } else {
611 1.0 // Low usage is excellent
612 };
613
614 // Eviction rate score (lower is better)
615 let total_requests = stats.global.total_hits + stats.global.total_misses;
616 let eviction_rate = if total_requests == 0 {
617 0.0
618 } else {
619 stats.global.total_evictions as f64 / total_requests as f64
620 };
621 let eviction_score = (1.0 - eviction_rate.min(1.0)).max(0.0);
622
623 // Overall score (weighted average)
624 let overall_score = (hit_rate_score * 0.5) + (memory_score * 0.3) + (eviction_score * 0.2);
625
626 CacheHealthScore {
627 overall: overall_score,
628 hit_rate: hit_rate_score,
629 memory_efficiency: memory_score,
630 eviction_health: eviction_score,
631 recommendations: self.generate_recommendations(&stats),
632 }
633 }
634
635 fn update_global_stats(&self) {
636 let result_stats = self.result_cache.stats();

Callers

nothing calls this directly

Calls 3

overall_hit_rateMethod · 0.80
get_statsMethod · 0.45

Tested by

no test coverage detected