Clear all entries from the cache
(&self)
| 285 | |
| 286 | /// Clear all entries from the cache |
| 287 | pub fn clear(&self) { |
| 288 | let mut entries = self.entries.write(); |
| 289 | let mut stats = self.stats.write(); |
| 290 | |
| 291 | let total_size = stats.total_size_bytes; |
| 292 | let entries_count = entries.len(); |
| 293 | |
| 294 | entries.clear(); |
| 295 | stats.total_entries = 0; |
| 296 | stats.total_size_bytes = 0; |
| 297 | stats.evictions += entries_count as u64; |
| 298 | |
| 299 | // Unregister memory usage |
| 300 | if total_size > 0 { |
| 301 | global_memory_monitor().record_query_deallocation(total_size as u64); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | /// Get current cache statistics |
| 306 | pub fn stats(&self) -> CacheStats { |