rez_next_cache/
lib.rs

1//! Intelligent caching system for rez-core
2//!
3//! This crate provides a unified, intelligent caching system that integrates
4//! with existing rez-core caches (SolverCache, RepositoryCache, RexCache).
5//! It features multi-level caching, predictive preheating, and adaptive tuning
6//! to achieve >90% cache hit rates.
7//!
8//! # Features
9//!
10//! - **Unified Cache Interface**: Common trait for all cache types
11//! - **Multi-level Caching**: L1 memory cache + L2 disk cache
12//! - **Predictive Preheating**: ML-based access pattern prediction
13//! - **Adaptive Tuning**: Real-time parameter optimization
14//! - **Performance Monitoring**: Comprehensive statistics and metrics
15//!
16//! # Architecture
17//!
18//! The caching system is built on top of existing rez-core cache implementations,
19//! reusing proven patterns and components while adding intelligent features.
20//!
21//! ```text
22//! ┌─────────────────────────────────────────────────────────────┐
23//! │                IntelligentCacheManager                     │
24//! ├─────────────────────────────────────────────────────────────┤
25//! │  L1 Cache (DashMap)  │  L2 Cache (RepositoryCache)        │
26//! ├─────────────────────────────────────────────────────────────┤
27//! │  PredictivePreheater │  AdaptiveTuner                     │
28//! ├─────────────────────────────────────────────────────────────┤
29//! │  SolverCache  │  RepositoryCache  │  RexCache             │
30//! └─────────────────────────────────────────────────────────────┘
31//! ```
32
33pub mod adaptive_tuner;
34pub mod benchmarks;
35pub mod cache_config;
36pub mod cache_stats;
37pub mod error;
38pub mod intelligent_manager;
39pub mod performance_monitor;
40pub mod predictive_preheater;
41pub mod unified_cache;
42
43#[cfg(test)]
44mod tests;
45
46// Re-export core types
47pub use adaptive_tuner::*;
48pub use benchmarks::*;
49pub use cache_config::*;
50pub use cache_stats::*;
51pub use error::*;
52pub use intelligent_manager::*;
53pub use performance_monitor::*;
54pub use predictive_preheater::*;
55pub use unified_cache::*;
56
57// Re-export existing cache components for compatibility
58// Temporarily disabled due to compilation errors in other crates
59// pub use rez_next_solver::cache::{EvictionStrategy, SolverCache, SolverCacheConfig, SolverCacheStats};
60// pub use rez_next_repository::cache::{RepositoryCache, CacheConfig as RepositoryCacheConfig, CacheStats as RepositoryCacheStats};
61// pub use rez_core_rex::cache::{RexCache, RexCacheConfig, RexCacheStats};
62
63/// Cache eviction strategies (copied from SolverCache for now)
64#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq)]
65pub enum EvictionStrategy {
66    /// Least Recently Used
67    LRU,
68    /// Least Frequently Used
69    LFU,
70    /// First In, First Out
71    FIFO,
72    /// Time-based expiration only
73    TTL,
74}
75
76/// Version information for the cache system
77pub const CACHE_VERSION: &str = env!("CARGO_PKG_VERSION");
78
79/// Default cache configuration
80pub const DEFAULT_L1_CAPACITY: usize = 10000;
81pub const DEFAULT_L2_CAPACITY: usize = 100000;
82pub const DEFAULT_TTL_SECONDS: u64 = 3600;
83pub const DEFAULT_MEMORY_LIMIT_MB: u64 = 100;