Returns an entry from the cache None will be returned if the cache doesn't contain the key
(&self, key: &K)
| 206 | /// |
| 207 | /// None will be returned if the cache doesn't contain the key |
| 208 | pub fn get(&self, key: &K) -> Option<V> { |
| 209 | if let Some(mut entry) = self.map.get_mut(key) { |
| 210 | let (value, counter_val) = entry.value_mut(); |
| 211 | let old_counter = *counter_val; |
| 212 | let new_counter = self.increment_counter(); |
| 213 | *counter_val = new_counter; |
| 214 | self.index |
| 215 | .on_cache_hit(old_counter, new_counter, key.clone().into()); |
| 216 | Some(value.clone()) |
| 217 | } else { |
| 218 | None |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | /// Inserts an entry into the cache |
| 223 | /// |
nothing calls this directly
no test coverage detected