MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / insert

Method insert

graphlite/src/cache/result_cache.rs:314–341  ·  view source on GitHub ↗

Insert result into cache

(
        &self,
        key: QueryCacheKey,
        result: QueryResult,
        execution_time: Duration,
        plan_hash: u64,
    )

Source from the content-addressed store, hash-verified

312
313 /// Insert result into cache
314 pub fn insert(
315 &self,
316 key: QueryCacheKey,
317 result: QueryResult,
318 execution_time: Duration,
319 plan_hash: u64,
320 ) {
321 let entry = QueryResultEntry {
322 result,
323 execution_time,
324 plan_hash,
325 metadata: CacheEntryMetadata::new(0, CacheLevel::L1), // Size calculated in CacheValue impl
326 compression_ratio: None,
327 };
328
329 let size = entry.size_bytes();
330
331 // Try L1 first
332 if size <= self.l1_max_memory {
333 self.insert_l1(key, entry);
334 } else {
335 // Fall back to L2
336 self.insert_l2(key, entry);
337 }
338
339 let mut stats = self.stats.write().unwrap();
340 stats.insertions += 1;
341 }
342
343 fn insert_l1(&self, key: QueryCacheKey, mut entry: QueryResultEntry) {
344 entry.metadata.level = CacheLevel::L1;

Callers 4

accessMethod · 0.45
update_positionsMethod · 0.45
insert_l1Method · 0.45
insert_l2Method · 0.45

Calls 4

insert_l1Method · 0.80
insert_l2Method · 0.80
unwrapMethod · 0.80
size_bytesMethod · 0.45

Tested by

no test coverage detected