MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / evict_cold

Function evict_cold

nodedb/src/engine/timeseries/recent_cache.rs:203–215  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201
202 #[test]
203 fn evict_cold() {
204 let mut cache = RecentWindowCache::new(1_000_000, 3_600_000);
205 // Old partition: max_ts=2000, will be cold at now=10_000_000.
206 cache.insert(T1, "m", make_partition(1000, 2000, 10));
207 // Recent partition: max_ts=9_000_000, within hot window at now=10_000_000.
208 cache.insert(T1, "m", make_partition(8_000_000, 9_000_000, 10));
209 assert_eq!(cache.len(), 2);
210
211 cache.evict_cold(10_000_000);
212 assert_eq!(cache.len(), 1);
213 assert!(cache.get(T1, "m", 1000).is_none()); // Evicted (cold).
214 assert!(cache.get(T1, "m", 8_000_000).is_some()); // Kept (hot).
215 }
216
217 #[test]
218 fn evict_tenant() {

Callers

nothing calls this directly

Calls 3

make_partitionFunction · 0.85
evict_coldMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected