MCPcopy Create free account
hub / github.com/cosdata/cosdata / get

Method get

src/models/lru_cache.rs:208–220  ·  view source on GitHub ↗

Returns an entry from the cache None will be returned if the cache doesn't contain the key

(&self, key: &K)

Source from the content-addressed store, hash-verified

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 ///

Callers

nothing calls this directly

Calls 3

increment_counterMethod · 0.80
on_cache_hitMethod · 0.80
cloneMethod · 0.80

Tested by

no test coverage detected