MCPcopy Create free account
hub / github.com/cosdata/cosdata / evict_lru

Method evict_lru

src/models/lru_cache.rs:289–308  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

287 }
288
289 fn evict_lru(&self) {
290 let mut oldest_pair = None;
291 let mut oldest_counter = u32::MAX;
292
293 for entry in self.map.iter() {
294 let (key, (_, counter_val)) = entry.pair();
295 if *counter_val < oldest_counter {
296 oldest_counter = *counter_val;
297 oldest_pair = Some(key.clone());
298 }
299 }
300
301 if let Some(key) = oldest_pair {
302 if let Some((key, (value, _))) = self.map.remove(&key) {
303 if let Some(evict_hook) = self.evict_hook {
304 evict_hook(&value);
305 }
306 }
307 }
308 }
309
310 fn evict_lru_probabilistic(&self, strategy: &ProbEviction) {
311 let num_to_evict = self

Callers 1

evictMethod · 0.80

Calls 3

cloneMethod · 0.80
removeMethod · 0.80
iterMethod · 0.45

Tested by

no test coverage detected