MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / insert

Method insert

nodedb/src/control/gateway/plan_cache.rs:158–166  ·  view source on GitHub ↗

Insert a plan. On capacity overflow, the oldest entry is evicted.

(&self, key: PlanCacheKey, plan: std::sync::Arc<PhysicalPlan>)

Source from the content-addressed store, hash-verified

156
157 /// Insert a plan. On capacity overflow, the oldest entry is evicted.
158 pub fn insert(&self, key: PlanCacheKey, plan: std::sync::Arc<PhysicalPlan>) {
159 let mut inner = self.inner.lock().unwrap_or_else(|p| p.into_inner());
160 // Remove any existing entry with the same key first.
161 inner.entries.retain(|e| e.key != key);
162 if inner.entries.len() >= inner.capacity {
163 inner.entries.pop_front();
164 }
165 inner.entries.push_back(CacheEntry { key, plan });
166 }
167
168 /// Evict all plan entries whose `version_set` references `name` at any
169 /// version other than `new_version`. Also removes the corresponding

Calls 3

lockMethod · 0.80
pop_frontMethod · 0.80
lenMethod · 0.45