Inserts an entry into the cache Note that if the entry is already present in cache, it will be overwritten
(&self, key: K, value: V)
| 224 | /// Note that if the entry is already present in cache, it will be |
| 225 | /// overwritten |
| 226 | pub fn insert(&self, key: K, value: V) { |
| 227 | let counter = self.increment_counter(); |
| 228 | self.map.insert(key.clone(), (value, counter)); |
| 229 | self.index.on_cache_miss(counter, key.into()); |
| 230 | self.evict(); |
| 231 | } |
| 232 | |
| 233 | /// Gets the value from the cache if it exists, else tries to |
| 234 | /// insert the result of the fn `f` into the cache and returns the |