oxirs-arq 0.2.4

Jena-style SPARQL algebra with extension points and query optimization
Documentation
//! Intelligent Cache Invalidation System
//!
//! This module provides an event-driven cache invalidation system that automatically
//! invalidates stale cache entries when RDF updates occur, ensuring cache consistency
//! while maintaining high performance.
//!
//! ## Features
//!
//! - **Dependency Tracking**: Automatic tracking of which cache entries depend on which RDF patterns
//! - **Event-Driven Invalidation**: Invalidate caches automatically on INSERT/DELETE operations
//! - **Multiple Strategies**: Choose from Immediate, Batched, BloomFilter, or CostBased invalidation
//! - **3-Level Coordination**: Unified coordination across result, plan, and optimizer caches
//! - **Low Overhead**: Target <1% performance overhead for cached queries
//! - **High Accuracy**: Zero stale cache entries guaranteed
//!
//! ## Architecture
//!
//! The system consists of two main components:
//!
//! 1. **InvalidationEngine**: Core dependency tracking and invalidation logic
//!    - Maintains bipartite graph: TriplePattern → CacheEntry
//!    - Tracks which cache entries depend on which RDF patterns
//!    - Efficiently finds affected entries when updates occur
//!
//! 2. **CacheCoordinator**: Unified coordinator for all cache levels
//!    - Manages result cache, plan cache, and optimizer cache
//!    - Propagates invalidations through all levels
//!    - Ensures cache coherence across the system
//!
//! ## Usage Example
//!
//! ```rust,ignore
//! use oxirs_arq::cache::{CacheCoordinator, InvalidationStrategy};
//!
//! // Create coordinator with batched invalidation
//! let coordinator = CacheCoordinator::new(InvalidationStrategy::Batched { batch_size: 100 });
//!
//! // Register a cache entry with its dependencies
//! let triple_patterns = vec![pattern1, pattern2];
//! coordinator.register_cache_entry("result_cache", cache_key, triple_patterns)?;
//!
//! // When RDF update occurs, invalidate affected entries
//! coordinator.on_rdf_insert(triple)?;
//!
//! // Coordinator automatically invalidates all affected cache entries across all levels
//! ```
//!
//! ## Performance
//!
//! - Invalidation overhead: <1% for cached queries
//! - Dependency lookup: O(1) average case
//! - Memory overhead: ~100 bytes per cache entry
//! - Throughput: >1M invalidations/second

pub mod coordinator;
pub mod invalidation_engine;

#[cfg(feature = "distributed-cache")]
pub mod coherence;
#[cfg(feature = "distributed-cache")]
pub mod distributed_cache;

pub use coordinator::{CacheCoordinator, CacheLevel, CoordinatorStatistics, InvalidationConfig};
pub use invalidation_engine::{
    DependencyGraph, DependencyGraphStatistics, InvalidationEngine, InvalidationStatistics,
    InvalidationStrategy, RdfUpdateListener,
};

#[cfg(feature = "distributed-cache")]
pub use coherence::{
    CacheCoherenceProtocol, CoherenceConfig, CoherenceError, CoherenceProtocol, CoherenceReport,
    CoherenceStatistics, ConsistencyLevel,
};
#[cfg(feature = "distributed-cache")]
pub use distributed_cache::{
    CacheKey, CacheValue, DistributedCache, DistributedCacheConfig, DistributedCacheError,
    DistributedCacheMetrics, InvalidationMessage,
};