Struct lsm_tree::BlockCache
source · pub struct BlockCache { /* private fields */ }
Expand description
Block cache, in which blocks are cached in-memory after being retrieved from disk. This speeds up consecutive queries to nearby data, improving read performance for hot data.
Examples
Sharing block cache between multiple trees
use lsm_tree::{Tree, Config, BlockCache};
use std::sync::Arc;
// Provide 10'000 blocks (10'000 * 4 KiB = 40 MB) of cache capacity
let block_cache = Arc::new(BlockCache::with_capacity_blocks(10_000));
let tree1 = Config::new(folder).block_cache(block_cache.clone()).open()?;
let tree2 = Config::new(folder).block_cache(block_cache.clone()).open()?;
Implementations§
source§impl BlockCache
impl BlockCache
sourcepub fn with_capacity_blocks(n: usize) -> Self
pub fn with_capacity_blocks(n: usize) -> Self
Creates a new block cache with roughly n
blocks of capacity
Multiply n by the block size to get the approximate byte count
Auto Trait Implementations§
impl RefUnwindSafe for BlockCache
impl Send for BlockCache
impl Sync for BlockCache
impl Unpin for BlockCache
impl UnwindSafe for BlockCache
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more