pub struct DecompressedChunkCache { /* private fields */ }Expand description
A shared, bytes-bounded, sharded decompressed-chunk cache.
Implementations§
Source§impl DecompressedChunkCache
impl DecompressedChunkCache
Sourcepub fn with_budget_bytes(total_budget_bytes: usize) -> Self
pub fn with_budget_bytes(total_budget_bytes: usize) -> Self
Create a cache with total_budget_bytes split across DEFAULT_SHARDS
shards.
Sourcepub fn with_budget_and_shards(
total_budget_bytes: usize,
shard_count: usize,
) -> Self
pub fn with_budget_and_shards( total_budget_bytes: usize, shard_count: usize, ) -> Self
Create a cache with total_budget_bytes split across shard_count shards.
shard_count is rounded UP to the next power of two (min 1) so shard
selection can mask instead of modulo. Unit tests use shard_count = 1 for
deterministic eviction ordering; production uses DEFAULT_SHARDS.
Sourcepub fn get(&self, key: &ChunkKey) -> Option<Arc<[u8]>>
pub fn get(&self, key: &ChunkKey) -> Option<Arc<[u8]>>
Look up a resident chunk. On a hit this bumps recency and returns an
Arc::clone (no chunk-sized allocation). On a miss returns None.
Sourcepub fn insert(&self, key: ChunkKey, data: Vec<u8>) -> Arc<[u8]>
pub fn insert(&self, key: ChunkKey, data: Vec<u8>) -> Arc<[u8]>
Insert data under key, returning the resident Arc<[u8]>.
The Vec<u8> is converted to Arc<[u8]> exactly once here; the returned
handle and any subsequent get share that one buffer. After
insertion the owning shard evicts LRU entries until it is within its byte
budget (never evicting the just-inserted entry).
Sourcepub fn resident_bytes(&self) -> usize
pub fn resident_bytes(&self) -> usize
Total resident decompressed bytes across all shards.
Sourcepub fn budget_bytes(&self) -> usize
pub fn budget_bytes(&self) -> usize
The configured total byte budget (budget_per_shard * shard count).
Sourcepub fn miss_count(&self) -> u64
pub fn miss_count(&self) -> u64
Cumulative cache misses (test/observability instrumentation).