MCPcopy Index your code
hub / github.com/GraphLite-AI/GraphLite / insert

Method insert

graphlite/src/cache/plan_cache.rs:181–226  ·  view source on GitHub ↗

Insert plan into cache

(
        &self,
        key: PlanCacheKey,
        logical_plan: LogicalPlan,
        physical_plan: PhysicalPlan,
        trace: Option<PlanTrace>,
        compilation_time: Duration,
    )

Source from the content-addressed store, hash-verified

179
180 /// Insert plan into cache
181 pub fn insert(
182 &self,
183 key: PlanCacheKey,
184 logical_plan: LogicalPlan,
185 physical_plan: PhysicalPlan,
186 trace: Option<PlanTrace>,
187 compilation_time: Duration,
188 ) {
189 let estimated_cost = physical_plan.estimated_cost;
190 let estimated_rows = physical_plan.estimated_rows;
191
192 let entry = PlanCacheEntry {
193 logical_plan,
194 physical_plan,
195 trace,
196 compilation_time,
197 estimated_cost,
198 estimated_rows,
199 metadata: CacheEntryMetadata::new(0, CacheLevel::L1).with_ttl(self.default_ttl),
200 usage_count: 0,
201 last_used: Instant::now(),
202 };
203
204 let size = entry.size_bytes();
205
206 // Check if we need to evict entries
207 self.evict_if_needed(size);
208
209 // Insert entry
210 {
211 let mut entries = self.entries.write().unwrap();
212 entries.insert(key, entry);
213 }
214
215 {
216 let mut current_memory = self.current_memory.write().unwrap();
217 *current_memory += size;
218 }
219
220 // Update stats
221 {
222 let mut stats = self.stats.write().unwrap();
223 stats.current_entries = self.entries.read().unwrap().len();
224 stats.current_memory_bytes = *self.current_memory.read().unwrap();
225 }
226 }
227
228 fn evict_if_needed(&self, incoming_size: usize) {
229 let current_memory = *self.current_memory.read().unwrap();

Callers 15

format_jsonMethod · 0.45
register_dependencyMethod · 0.45
cascade_invalidationMethod · 0.45
graph_tag_basedMethod · 0.45
cache_query_resultMethod · 0.45
cache_query_planMethod · 0.45
cache_subquery_resultMethod · 0.45
register_functionMethod · 0.45
bind_variableMethod · 0.45
update_from_graphMethod · 0.45

Calls 5

with_ttlMethod · 0.80
unwrapMethod · 0.80
size_bytesMethod · 0.45
evict_if_neededMethod · 0.45
lenMethod · 0.45