Skip to main content

Module cache

Module cache 

Source
Expand description

Block cache — an LRU cache of decompressed SSTable data blocks.

LevelDB uses a generic sharded LRU cache with custom deleters and opaque handles (util/cache.cc). In Rust, Arc<Block> replaces the handle + deleter pattern: dropping the cache’s copy is enough; any BlockIter that already cloned the Arc<Vec<u8>> remains valid independently.

The key is (cache_id, block_offset). Each Table gets a unique cache_id from BlockCache::new_id so blocks from different files never collide even when file numbers are reused after compaction.

Default capacity: 8 MiB (matching LevelDB’s Options::block_cache default).

Structs§

BlockCache
An LRU cache of decompressed SSTable data blocks, keyed by (cache_id, block_offset).

Constants§

DEFAULT_BLOCK_CACHE_CAPACITY
Default block cache capacity in bytes.