Strand Blobs
Chunks and Cache
Chunk layout and cache for Strand Blobs — BLAKE3 chunking, ChunkCache for hot reads, and dedup statistics across blobs.
Purpose
Chunked blob storage with deduplication, cache, writer/reader APIs, repair, metrics, and policy hooks.
This page follows the real source shape for Strand Blobs and explains the workflow a developer is likely to use first.
Developer workflow
Start from the smallest constructor or builder, perform one meaningful operation, inspect the returned state, then add the relevant policy, storage, or network integration. The examples below should be expanded whenever the crate API changes.
Primary types to know
AllowAllBlobPolicy— models/strand-blobs/src/policy.rsBlobConfig— models/strand-blobs/src/config.rsBlobEntry— models/strand-blobs/src/chunk.rsBlobId— models/strand-blobs/src/blob.rsBlobInfo— models/strand-blobs/src/blob.rsBlobMetadata— models/strand-blobs/src/blob.rsBlobMetrics— models/strand-blobs/src/metrics.rsBlobMetricsSnapshot— models/strand-blobs/src/metrics.rsBlobReader— models/strand-blobs/src/reader.rsBlobStore— models/strand-blobs/src/store.rsBlobWriter— models/strand-blobs/src/writer.rsChunkCache— models/strand-blobs/src/cache.rs
Example shape
use bytes::Bytes;
use strand_blobs::{BlobConfig, ChunkCache, ChunkIndex, CompressionType};
fn main() {
// The blob store caches recently read chunks in an LRU keyed by chunk index.
// 4 MiB is a sensible default for hot path metadata; tune up for cold reads.
let cache = ChunkCache::new(4 * 1024 * 1024);
cache.insert(0, Bytes::from_static(b"chunk-0"));
cache.insert(1, Bytes::from_static(b"chunk-1"));
// Lookups are constant-time and update hit/miss counters used by metrics().
let hit = cache.get(&0);
let miss = cache.get(&99);
assert!(hit.is_some());
assert!(miss.is_none());
// BlobConfig controls the chunk size and compression applied at put time.
let cfg = BlobConfig {
chunk_size: 1024 * 1024,
compression: CompressionType::Zstd,
..BlobConfig::default()
};
let _ = ChunkIndex::default();
println!(
"cache_entries={} cache_hits={} cache_misses={} chunk_size={}",
cache.len(),
cache.hits(),
cache.misses(),
cfg.chunk_size,
);
}