MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / insert

Method insert

atomic-repository/src/changestore/cache.rs:77–91  ·  view source on GitHub ↗

Insert an entry into the cache. If the cache is at capacity, the least recently used entry is evicted first.

(&mut self, key: K, value: V)

Source from the content-addressed store, hash-verified

75 /// If the cache is at capacity, the least recently used entry
76 /// is evicted first.
77 pub(crate) fn insert(&mut self, key: K, value: V) {
78 // Evict if at capacity
79 if self.entries.len() >= self.capacity && !self.entries.contains_key(&key) {
80 self.evict_lru();
81 }
82
83 self.access_counter += 1;
84 self.entries.insert(
85 key,
86 CacheEntry {
87 value,
88 last_access: self.access_counter,
89 },
90 );
91 }
92
93 /// Remove an entry from the cache.
94 ///

Callers 15

create_fileMethod · 0.45
create_directoryMethod · 0.45
saveMethod · 0.45
addMethod · 0.45
renameMethod · 0.45
add_entryMethod · 0.45
execute_planFunction · 0.45

Calls 3

contains_keyMethod · 0.80
evict_lruMethod · 0.80
lenMethod · 0.45