Evicts entries from the LRU cache until `memory_used` is lower than `memory_limit`.
(&mut self)
| 87 | |
| 88 | /// Evicts entries from the LRU cache until `memory_used` is lower than `memory_limit`. |
| 89 | fn evict_entries(&mut self) { |
| 90 | while self.memory_used > self.memory_limit { |
| 91 | if let Some(removed) = self.lru_queue.pop() { |
| 92 | self.memory_used -= removed.1.file_metadata.memory_size(); |
| 93 | } else { |
| 94 | // cache is empty while memory_used > memory_limit, cannot happen |
| 95 | debug_assert!( |
| 96 | false, |
| 97 | "cache is empty while memory_used > memory_limit, cannot happen" |
| 98 | ); |
| 99 | return; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | /// Removes an entry from the cache and returns it, if it exists. |
| 105 | fn remove(&mut self, k: &Path) -> Option<CachedFileMetadataEntry> { |
no test coverage detected