Expand description
Cache warming strategies for cold starts.
This module implements intelligent cache pre-loading strategies to minimize cold start latency. It analyzes access patterns and proactively loads frequently accessed content into cache during system startup or idle periods.
§Example
use chie_core::cache_warming::{CacheWarmer, WarmingStrategy, WarmingConfig};
use std::path::PathBuf;
let config = WarmingConfig {
strategy: WarmingStrategy::FrequencyBased,
max_items: 100,
max_bytes: 100 * 1024 * 1024, // 100 MB
access_log_path: PathBuf::from("/tmp/access.log"),
warmup_on_startup: true,
};
let mut warmer = CacheWarmer::new(config)?;
// Record access patterns during runtime
warmer.record_access("QmContent1".to_string(), 1024).await;
warmer.record_access("QmContent2".to_string(), 2048).await;
// Get warming candidates for next cold start
let candidates = warmer.get_warming_candidates()?;
for candidate in candidates {
println!("Should warm: {} (score: {})", candidate.cid, candidate.score);
}Structs§
- Cache
Warmer - Cache warmer for pre-loading content.
- Warming
Candidate - Warming candidate with priority score.
- Warming
Config - Cache warming configuration.
- Warming
Stats - Warming statistics.
Enums§
- Warming
Error - Cache warming error types.
- Warming
Strategy - Cache warming strategy.