Removes an entry from the cache and returns it, if it exists.
(&mut self, k: &Path)
| 103 | |
| 104 | /// Removes an entry from the cache and returns it, if it exists. |
| 105 | fn remove(&mut self, k: &Path) -> Option<CachedFileMetadataEntry> { |
| 106 | if let Some(old_entry) = self.lru_queue.remove(k) { |
| 107 | self.memory_used -= old_entry.file_metadata.memory_size(); |
| 108 | self.cache_hits.remove(k); |
| 109 | Some(old_entry) |
| 110 | } else { |
| 111 | None |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | /// Returns the number of entries currently cached. |
| 116 | fn len(&self) -> usize { |