Expand description
Chunk prefetching for improved performance.
This module provides intelligent chunk prefetching that predicts which chunks will be needed next and pre-loads them into memory.
§Examples
use chie_core::prefetch::{ChunkPrefetcher, PrefetchConfig};
let config = PrefetchConfig::default();
let prefetcher = ChunkPrefetcher::new(config);
// Record access pattern (automatically predicts next chunks)
let predicted = prefetcher.record_access("QmContent123", 0).await;
println!("Predicted chunks after access 0: {:?}", predicted);
let predicted = prefetcher.record_access("QmContent123", 1).await;
println!("Predicted chunks after access 1: {:?}", predicted);
// Cache a chunk for faster retrieval
prefetcher.put_cached("QmContent123", 2, vec![1, 2, 3, 4]).await;
// Retrieve from cache
if let Some(data) = prefetcher.get_cached("QmContent123", 2).await {
println!("Retrieved {} bytes from cache", data.len());
}Structs§
- Cached
Chunk - Cached chunk entry.
- Chunk
Prefetcher - Chunk prefetcher for intelligent caching and prediction.
- Prefetch
Config - Prefetch configuration.
- Prefetch
Hint - Prefetch hint for external prefetch requests.
- Prefetch
Stats - Prefetch statistics.
- Prefetcher
Builder - Builder for ChunkPrefetcher.
Enums§
- Pattern
Type - Detected access pattern type.