Evict the least recently used entry.
(&mut self)
| 104 | |
| 105 | /// Evict the least recently used entry. |
| 106 | fn evict_lru(&mut self) { |
| 107 | if let Some(lru_key) = self |
| 108 | .entries |
| 109 | .iter() |
| 110 | .min_by_key(|(_, entry)| entry.last_access) |
| 111 | .map(|(k, _)| k.clone()) |
| 112 | { |
| 113 | self.entries.remove(&lru_key); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /// Get the current number of entries in the cache. |
| 118 | #[cfg(test)] |