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

Method evict_cold

nodedb/src/engine/timeseries/recent_cache.rs:106–121  ·  view source on GitHub ↗

Evict partitions that are no longer in the hot window.

(&mut self, now_ms: i64)

Source from the content-addressed store, hash-verified

104
105 /// Evict partitions that are no longer in the hot window.
106 pub fn evict_cold(&mut self, now_ms: i64) {
107 let cutoff = now_ms - self.hot_window_ms;
108 let cold_keys: Vec<CacheKey> = self
109 .entries
110 .iter()
111 .filter(|(_, p)| p.max_ts < cutoff)
112 .map(|(k, _)| k.clone())
113 .collect();
114
115 for key in cold_keys {
116 if let Some(removed) = self.entries.remove(&key) {
117 self.current_bytes -= removed.memory_bytes;
118 }
119 self.order.retain(|k| k != &key);
120 }
121 }
122
123 /// Evict all cached entries belonging to a specific tenant.
124 ///

Callers 1

evict_coldFunction · 0.80

Calls 4

collectMethod · 0.80
iterMethod · 0.45
cloneMethod · 0.45
removeMethod · 0.45

Tested by 1

evict_coldFunction · 0.64