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

Function test_cleanup

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

Source from the content-addressed store, hash-verified

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() {

Callers

nothing calls this directly

Calls 3

insert_with_ttlMethod · 0.80
cleanupMethod · 0.45
statsMethod · 0.45

Tested by

no test coverage detected