MCPcopy Create free account
hub / github.com/erans/pgsqlite / test_hit_rate_calculation

Function test_hit_rate_calculation

src/cache/ttl_cache.rs:818–830  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

816
817 #[test]
818 fn test_hit_rate_calculation() {
819 let cache = TtlCache::new();
820
821 cache.insert("key1".to_string(), "value1".to_string());
822
823 // 2 hits, 1 miss
824 cache.get(&"key1".to_string());
825 cache.get(&"key1".to_string());
826 cache.get(&"nonexistent".to_string());
827
828 let stats = cache.stats();
829 assert!((stats.hit_rate() - 0.6666666666666666).abs() < 0.0001);
830 }
831
832 #[test]
833 fn test_cache_factory() {

Callers

nothing calls this directly

Calls 3

insertMethod · 0.45
getMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected