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

Function test_ttl_expiration

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

Source from the content-addressed store, hash-verified

699
700 #[test]
701 fn test_ttl_expiration() {
702 let cache = TtlCache::new();
703
704 // Insert with short TTL
705 cache.insert_with_ttl("key1".to_string(), "value1".to_string(), Duration::from_millis(50));
706
707 // Should be available immediately
708 assert_eq!(cache.get(&"key1".to_string()), Some("value1".to_string()));
709
710 // Wait for expiration
711 thread::sleep(Duration::from_millis(100));
712
713 // Should be expired
714 assert_eq!(cache.get(&"key1".to_string()), None);
715
716 let stats = cache.stats();
717 assert_eq!(stats.expired_evictions, 1);
718 }
719
720 #[test]
721 fn test_max_entries_eviction() {

Callers

nothing calls this directly

Calls 2

insert_with_ttlMethod · 0.80
statsMethod · 0.45

Tested by

no test coverage detected