Invalidate plans by schema hash
(&self, schema_hash: u64)
| 279 | |
| 280 | /// Invalidate plans by schema hash |
| 281 | pub fn invalidate_by_schema(&self, schema_hash: u64) { |
| 282 | let mut entries = self.entries.write().unwrap(); |
| 283 | let mut removed_size = 0; |
| 284 | |
| 285 | entries.retain(|key, entry| { |
| 286 | if key.schema_hash == schema_hash { |
| 287 | removed_size += entry.size_bytes(); |
| 288 | false |
| 289 | } else { |
| 290 | true |
| 291 | } |
| 292 | }); |
| 293 | |
| 294 | { |
| 295 | let mut current_memory = self.current_memory.write().unwrap(); |
| 296 | *current_memory = current_memory.saturating_sub(removed_size); |
| 297 | } |
| 298 | |
| 299 | { |
| 300 | let mut stats = self.stats.write().unwrap(); |
| 301 | stats.current_entries = entries.len(); |
| 302 | stats.current_memory_bytes = *self.current_memory.read().unwrap(); |
| 303 | } |
| 304 | } |
| 305 | |
| 306 | /// Get cache statistics |
| 307 | pub fn stats(&self) -> PlanCacheStats { |
no test coverage detected