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

Function test_emergency_memory_eviction

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

Source from the content-addressed store, hash-verified

895
896 #[test]
897 fn test_emergency_memory_eviction() {
898 let config = TtlCacheConfig {
899 memory_pressure_threshold: 1, // 1MB threshold (very low for testing)
900 memory_pressure_enabled: true,
901 ..Default::default()
902 };
903 let cache = TtlCache::with_config(config);
904
905 // Insert entries that exceed the memory threshold
906 for i in 0..10 {
907 cache.insert_with_ttl_and_size(
908 format!("key{}", i),
909 format!("value{}", i),
910 Duration::from_secs(60),
911 200_000 // 200KB each
912 );
913 }
914
915 // This should trigger emergency eviction during maybe_cleanup
916 cache.insert("trigger".to_string(), "value".to_string());
917
918 // Validate that memory tracking is consistent after emergency eviction
919 assert!(cache.validate_memory_tracking());
920 }
921}

Callers

nothing calls this directly

Calls 2

insertMethod · 0.45

Tested by

no test coverage detected