Record a cache hit and update access statistics
(&self, cache_key: &str)
| 363 | |
| 364 | /// Record a cache hit and update access statistics |
| 365 | fn record_cache_hit(&self, cache_key: &str) { |
| 366 | let mut statements = self.statements.write().unwrap(); |
| 367 | if let Some(entry) = statements.get_mut(cache_key) { |
| 368 | entry.access_count += 1; |
| 369 | entry.last_used = Instant::now(); |
| 370 | } |
| 371 | |
| 372 | let mut stats = self.stats.write().unwrap(); |
| 373 | stats.cache_hits += 1; |
| 374 | stats.average_hit_rate = stats.cache_hits as f64 / stats.total_queries as f64; |
| 375 | } |
| 376 | |
| 377 | /// Evict the least valuable entry from the cache |
| 378 | fn evict_least_valuable(&self, statements: &mut HashMap<String, CachedStatementEntry>) { |
no outgoing calls
no test coverage detected