Skip to main content

Module cached_store

Module cached_store 

Source
Expand description

Write-back LRU cache that wraps any BlockStore.

Dirty blocks accumulate in memory and are flushed to the inner store in batch on sync(). When a dirty entry is evicted by cache pressure it is written-back immediately so no data is lost.

§Example

use doublecrypt_core::block_store::{BlockStore, MemoryBlockStore};
use doublecrypt_core::cached_store::CachedBlockStore;

let inner = MemoryBlockStore::new(4096, 256);
let cached = CachedBlockStore::new(inner, 64); // cache up to 64 blocks

cached.write_block(0, &vec![0xAB; 4096]).unwrap();
// Block is dirty in cache — not yet written to inner store.

cached.sync().unwrap();
// Now flushed.

Structs§

CachedBlockStore
Write-back LRU block cache.