Evict partitions that are no longer in the hot window.
(&mut self, now_ms: i64)
| 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 | /// |