MCPcopy Create free account
hub / github.com/erans/pgsqlite / insert

Method insert

src/cache/mod.rs:73–88  ·  view source on GitHub ↗
(&self, key: K, value: V)

Source from the content-addressed store, hash-verified

71 }
72
73 pub fn insert(&self, key: K, value: V) {
74 let mut cache = self.cache.write().unwrap();
75
76 // Simple eviction: remove oldest entry if at capacity
77 if cache.len() >= self.capacity && !cache.contains_key(&key)
78 && let Some((oldest_key, _)) = cache.iter()
79 .min_by_key(|(_, entry)| entry.last_accessed) {
80 let oldest_key = oldest_key.clone();
81 cache.remove(&oldest_key);
82 }
83
84 cache.insert(key, CacheEntry {
85 value,
86 last_accessed: Instant::now(),
87 });
88 }
89
90 pub fn invalidate(&self, key: &K) {
91 self.cache.write().unwrap().remove(key);

Callers 15

get_metadata_columnsMethod · 0.45
get_sqlite_columnsMethod · 0.45
get_enum_typeMethod · 0.45
get_enum_type_by_oidMethod · 0.45
get_enum_valuesMethod · 0.45
cache_metadataMethod · 0.45
test_managed_cache_traitFunction · 0.45
test_cache_statsFunction · 0.45
get_schemaMethod · 0.45

Calls 3

lenMethod · 0.45
cloneMethod · 0.45
removeMethod · 0.45

Tested by 15

test_managed_cache_traitFunction · 0.36
test_cache_statsFunction · 0.36
test_context_mergingFunction · 0.36
test_simple_equalityFunction · 0.36
test_in_listFunction · 0.36
test_like_patternFunction · 0.36