Module prefetch

Module prefetch 

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

CachedChunk
Cached chunk entry.
ChunkPrefetcher
Chunk prefetcher for intelligent caching and prediction.
PrefetchConfig
Prefetch configuration.
PrefetchHint
Prefetch hint for external prefetch requests.
PrefetchStats
Prefetch statistics.
PrefetcherBuilder
Builder for ChunkPrefetcher.

Enums§

PatternType
Detected access pattern type.