Invalidate caches when graph data changes
(&self, table: Option<String>, affected_rows: u64)
| 417 | |
| 418 | /// Invalidate caches when graph data changes |
| 419 | pub fn invalidate_on_data_change(&self, table: Option<String>, affected_rows: u64) { |
| 420 | let mut graph_version = self.graph_version.write().unwrap(); |
| 421 | *graph_version += 1; |
| 422 | |
| 423 | // Create invalidation event |
| 424 | let event = InvalidationEvent::DataUpdate { |
| 425 | table: table.unwrap_or_else(|| "unknown".to_string()), |
| 426 | affected_rows, |
| 427 | columns: vec![], // Could be enhanced to track specific columns |
| 428 | }; |
| 429 | |
| 430 | // Handle invalidation through the manager |
| 431 | let result = self.invalidation_manager.handle_event(event.clone()); |
| 432 | |
| 433 | // Invalidate result cache and subquery cache entries with old graph version |
| 434 | self.result_cache |
| 435 | .invalidate_by_graph_version(*graph_version); |
| 436 | self.subquery_cache |
| 437 | .invalidate_by_graph_version(*graph_version); |
| 438 | |
| 439 | self.record_event(CacheEvent::Invalidation { |
| 440 | strategy: result.strategy_used, |
| 441 | affected_entries: result.entries_invalidated, |
| 442 | timestamp: Instant::now(), |
| 443 | }); |
| 444 | |
| 445 | self.update_global_stats(); |
| 446 | } |
| 447 | |
| 448 | /// Invalidate caches when schema changes |
| 449 | pub fn invalidate_on_schema_change(&self, table: String, change_type: String) { |
no test coverage detected