Get an entry from the cache, updating its access time. Returns `None` if the key is not in the cache.
(&mut self, key: &K)
| 50 | /// |
| 51 | /// Returns `None` if the key is not in the cache. |
| 52 | pub(crate) fn get(&mut self, key: &K) -> Option<&V> { |
| 53 | if let Some(entry) = self.entries.get_mut(key) { |
| 54 | self.access_counter += 1; |
| 55 | entry.last_access = self.access_counter; |
| 56 | Some(&entry.value) |
| 57 | } else { |
| 58 | None |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /// Read an entry without updating its access time. |
| 63 | /// |