()
| 749 | |
| 750 | #[test] |
| 751 | fn test_cleanup() { |
| 752 | let cache = TtlCache::new(); |
| 753 | |
| 754 | // Insert entries with different TTLs |
| 755 | cache.insert_with_ttl("key1".to_string(), "value1".to_string(), Duration::from_millis(50)); |
| 756 | cache.insert_with_ttl("key2".to_string(), "value2".to_string(), Duration::from_secs(60)); |
| 757 | |
| 758 | assert_eq!(cache.len(), 2); |
| 759 | |
| 760 | // Wait for first entry to expire |
| 761 | thread::sleep(Duration::from_millis(100)); |
| 762 | |
| 763 | // Force cleanup |
| 764 | cache.cleanup(); |
| 765 | |
| 766 | assert_eq!(cache.len(), 1); |
| 767 | assert_eq!(cache.get(&"key2".to_string()), Some("value2".to_string())); |
| 768 | |
| 769 | let stats = cache.stats(); |
| 770 | assert_eq!(stats.cleanup_runs, 1); |
| 771 | } |
| 772 | |
| 773 | #[test] |
| 774 | fn test_cache_clear() { |
nothing calls this directly
no test coverage detected