Insert result into cache
(
&self,
key: QueryCacheKey,
result: QueryResult,
execution_time: Duration,
plan_hash: u64,
)
| 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; |
no test coverage detected