()
| 415 | |
| 416 | #[test] |
| 417 | fn hit_rate_tracking() { |
| 418 | let mut cache = DocCache::new(16); |
| 419 | cache.put(0, 1, "c", "a", b"1"); |
| 420 | cache.get(0, 1, "c", "a"); // hit |
| 421 | cache.get(0, 1, "c", "a"); // hit |
| 422 | cache.get(0, 1, "c", "b"); // miss |
| 423 | assert!((cache.hit_rate() - 0.6667).abs() < 0.01); |
| 424 | assert_eq!(cache.total_lookups(), 3); |
| 425 | } |
| 426 | |
| 427 | // ── Per-database isolation ───────────────────────────────────────────── |
| 428 |