Module cache_warming

Module cache_warming 

Source
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§

CacheWarmer
Cache warmer for pre-loading content.
WarmingCandidate
Warming candidate with priority score.
WarmingConfig
Cache warming configuration.
WarmingStats
Warming statistics.

Enums§

WarmingError
Cache warming error types.
WarmingStrategy
Cache warming strategy.