()
| 473 | |
| 474 | #[test] |
| 475 | fn test_memory_aware_cache_manager() { |
| 476 | let config = MemoryAwareCacheConfig { |
| 477 | enable_pressure_monitoring: true, |
| 478 | pressure_threshold_mb: 1, // Very low for testing |
| 479 | critical_threshold_mb: 2, |
| 480 | check_interval: Duration::from_millis(100), |
| 481 | ..Default::default() |
| 482 | }; |
| 483 | |
| 484 | let manager = MemoryAwareCacheManager::with_config(config); |
| 485 | |
| 486 | // Create and register a test cache |
| 487 | let cache: Arc<TtlCache<String, String>> = manager.create_and_register_cache("test_cache".to_string()); |
| 488 | |
| 489 | // Add some entries |
| 490 | for i in 0..10 { |
| 491 | cache.insert(format!("key_{}", i), format!("value_{}", i)); |
| 492 | } |
| 493 | |
| 494 | let stats = manager.get_stats(); |
| 495 | assert_eq!(stats.total_managed_caches, 1); |
| 496 | assert!(stats.total_entries > 0); |
| 497 | |
| 498 | // Test forced eviction |
| 499 | let evicted = manager.force_eviction(0.5); |
| 500 | assert!(evicted > 0); |
| 501 | } |
| 502 | |
| 503 | #[test] |
| 504 | fn test_managed_cache_trait() { |
nothing calls this directly
no test coverage detected