oxirs_vec/adaptive_intelligent_caching/
config.rs

1//! Configuration for the adaptive intelligent caching system
2
3use serde::{Deserialize, Serialize};
4
5/// Configuration for the adaptive cache system
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct CacheConfiguration {
8    /// Maximum total cache size in bytes
9    pub max_total_size_bytes: u64,
10    /// Number of cache tiers
11    pub num_tiers: u32,
12    /// Tier size distribution
13    pub tier_size_ratios: Vec<f64>,
14    /// Default TTL for cached items
15    pub default_ttl_seconds: u64,
16    /// Optimization frequency
17    pub optimization_interval_seconds: u64,
18    /// ML model update frequency
19    pub ml_update_interval_seconds: u64,
20    /// Enable predictive prefetching
21    pub enable_prefetching: bool,
22    /// Enable adaptive optimization
23    pub enable_adaptive_optimization: bool,
24    /// Performance monitoring settings
25    pub monitoring_config: MonitoringConfiguration,
26}
27
28#[derive(Debug, Clone, Serialize, Deserialize)]
29pub struct MonitoringConfiguration {
30    pub enable_detailed_metrics: bool,
31    pub metrics_retention_days: u32,
32    pub alert_thresholds: AlertThresholds,
33    pub export_prometheus: bool,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37pub struct AlertThresholds {
38    pub min_hit_rate: f64,
39    pub max_latency_p99_ms: f64,
40    pub max_memory_utilization: f64,
41    pub min_cache_efficiency: f64,
42}
43
44impl Default for CacheConfiguration {
45    fn default() -> Self {
46        Self {
47            max_total_size_bytes: 1024 * 1024 * 1024, // 1GB
48            num_tiers: 3,
49            tier_size_ratios: vec![0.5, 0.3, 0.2], // 50%, 30%, 20%
50            default_ttl_seconds: 3600,             // 1 hour
51            optimization_interval_seconds: 300,    // 5 minutes
52            ml_update_interval_seconds: 900,       // 15 minutes
53            enable_prefetching: true,
54            enable_adaptive_optimization: true,
55            monitoring_config: MonitoringConfiguration {
56                enable_detailed_metrics: true,
57                metrics_retention_days: 7,
58                alert_thresholds: AlertThresholds {
59                    min_hit_rate: 0.8,
60                    max_latency_p99_ms: 100.0,
61                    max_memory_utilization: 0.9,
62                    min_cache_efficiency: 0.7,
63                },
64                export_prometheus: true,
65            },
66        }
67    }
68}