Implement simple persistent cache with automatic saving on status changes

This commit is contained in:
2025-10-21 20:12:19 +02:00
parent 338c4457a5
commit a08670071c
6 changed files with 116 additions and 104 deletions

View File

@@ -3,23 +3,13 @@ use serde::{Deserialize, Serialize};
/// Cache configuration
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct CacheConfig {
pub enabled: bool,
pub default_ttl_seconds: u64,
pub max_entries: usize,
pub warming_timeout_seconds: u64,
pub background_refresh_enabled: bool,
pub cleanup_interval_seconds: u64,
pub persist_path: String,
}
impl Default for CacheConfig {
fn default() -> Self {
Self {
enabled: true,
default_ttl_seconds: 30,
max_entries: 10000,
warming_timeout_seconds: 3,
background_refresh_enabled: true,
cleanup_interval_seconds: 1800,
persist_path: "/var/lib/cm-dashboard/cache.json".to_string(),
}
}
}