pub struct BlockEngineBuilder<K, V, P>{ /* private fields */ }
Expand description
Builder for the block-based disk cache engine.
The block-based disk cache engine is suitable for general cache entries with size from 2K to hundreds of MiBs.
Each cache entry will be aligned to a multiplier of 4K on disk, hence too small cache entries will lead to heavy internal fragmentation.
The disk cache evicts cache entries in block unit.
Implementations§
Source§impl<K, V, P> BlockEngineBuilder<K, V, P>
impl<K, V, P> BlockEngineBuilder<K, V, P>
Sourcepub fn new(device: Arc<dyn Device>) -> BlockEngineBuilder<K, V, P>
pub fn new(device: Arc<dyn Device>) -> BlockEngineBuilder<K, V, P>
Create a new block-based disk cache engine builder with default configurations.
Sourcepub fn with_block_size(self, block_size: usize) -> BlockEngineBuilder<K, V, P>
pub fn with_block_size(self, block_size: usize) -> BlockEngineBuilder<K, V, P>
Set the block size for the block-based disk cache engine.
Block is the minimal cache eviction unit for the block-based disk cache, its size also limits the max cacheable entry size.
The block size must be 4K-aligned. the given value is not 4K-aligned, it will be automatically aligned up.
Default: 16 MiB
.
Sourcepub fn with_indexer_shards(
self,
indexer_shards: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_indexer_shards( self, indexer_shards: usize, ) -> BlockEngineBuilder<K, V, P>
Set the shard num of the indexer. Each shard has its own lock.
Default: 64
.
Sourcepub fn with_recover_concurrency(
self,
recover_concurrency: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_recover_concurrency( self, recover_concurrency: usize, ) -> BlockEngineBuilder<K, V, P>
Set the recover concurrency for the disk cache store.
Default: 8
.
Sourcepub fn with_flushers(self, flushers: usize) -> BlockEngineBuilder<K, V, P>
pub fn with_flushers(self, flushers: usize) -> BlockEngineBuilder<K, V, P>
Set the flusher count for the disk cache store.
The flusher count limits how many blocks can be concurrently written.
Default: 1
.
Sourcepub fn with_admission_filter(
self,
filter: StorageFilter,
) -> BlockEngineBuilder<K, V, P>
pub fn with_admission_filter( self, filter: StorageFilter, ) -> BlockEngineBuilder<K, V, P>
Set the admission filter for th disk cache store.
The admission filter is used to pick the entries that can be inserted into the disk cache store.
Default: Admit all.
Sourcepub fn with_reclaimers(self, reclaimers: usize) -> BlockEngineBuilder<K, V, P>
pub fn with_reclaimers(self, reclaimers: usize) -> BlockEngineBuilder<K, V, P>
Set the reclaimer count for the disk cache store.
The reclaimer count limits how many blocks can be concurrently reclaimed.
Default: 1
.
Sourcepub fn with_buffer_pool_size(
self,
buffer_pool_size: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_buffer_pool_size( self, buffer_pool_size: usize, ) -> BlockEngineBuilder<K, V, P>
Set the total flush buffer pool size.
Each flusher shares a volume at threshold / flushers
.
If the buffer of the flush queue exceeds the threshold, the further entries will be ignored.
Default: 16 MiB.
Sourcepub fn with_blob_index_size(
self,
blob_index_size: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_blob_index_size( self, blob_index_size: usize, ) -> BlockEngineBuilder<K, V, P>
Set the blob index size for each blob.
A larger blob index size can hold more blob entries, but it will also increase the io size of each blob part write.
NOTE: The size will be aligned up to a multiplier of 4K.
Default: 4 KiB
Sourcepub fn with_submit_queue_size_threshold(
self,
submit_queue_size_threshold: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_submit_queue_size_threshold( self, submit_queue_size_threshold: usize, ) -> BlockEngineBuilder<K, V, P>
Set the submit queue size threshold.
If the total entry estimated size in the submit queue exceeds the threshold, the further entries will be ignored.
Default: buffer_pool_size
* 2.
Sourcepub fn with_clean_block_threshold(
self,
clean_block_threshold: usize,
) -> BlockEngineBuilder<K, V, P>
pub fn with_clean_block_threshold( self, clean_block_threshold: usize, ) -> BlockEngineBuilder<K, V, P>
Set the clean block threshold for the disk cache store.
The reclaimers only work when the clean block count is equal to or lower than the clean block threshold.
Default: the same value as the reclaimers
.
Sourcepub fn with_eviction_pickers(
self,
eviction_pickers: Vec<Box<dyn EvictionPicker>>,
) -> BlockEngineBuilder<K, V, P>
pub fn with_eviction_pickers( self, eviction_pickers: Vec<Box<dyn EvictionPicker>>, ) -> BlockEngineBuilder<K, V, P>
Set the eviction pickers for th disk cache store.
The eviction picker is used to pick the block to reclaim.
The eviction pickers are applied in order. If the previous eviction picker doesn’t pick any block, the next one will be applied.
If no eviction picker picks a block, a block will be picked randomly.
Default: [ invalid ratio picker { threshold = 0.8 }, fifo picker ]
Sourcepub fn with_reinsertion_filter(
self,
filter: StorageFilter,
) -> BlockEngineBuilder<K, V, P>
pub fn with_reinsertion_filter( self, filter: StorageFilter, ) -> BlockEngineBuilder<K, V, P>
Set the reinsertion filter for th disk cache store.
The reinsertion filter is used to pick the entries that can be reinsertion into the disk cache store while reclaiming.
Note: Only extremely important entries should be picked. If too many entries are picked, both insertion and reinsertion will be stuck.
Default: Reject all.
Sourcepub fn with_tombstone_log(self, enable: bool) -> BlockEngineBuilder<K, V, P>
pub fn with_tombstone_log(self, enable: bool) -> BlockEngineBuilder<K, V, P>
Enable the tombstone log.
For updatable cache, either the tombstone log or crate::engine::RecoverMode::None
must be enabled to prevent
from the phantom entries after reopen.
Sourcepub async fn build(
self: Box<BlockEngineBuilder<K, V, P>>,
__arg1: EngineBuildContext,
) -> Result<Arc<BlockEngine<K, V, P>>, Error>
pub async fn build( self: Box<BlockEngineBuilder<K, V, P>>, __arg1: EngineBuildContext, ) -> Result<Arc<BlockEngine<K, V, P>>, Error>
Build the block-based disk cache engine with the given configurations.
Trait Implementations§
Source§impl<K, V, P> Debug for BlockEngineBuilder<K, V, P>
impl<K, V, P> Debug for BlockEngineBuilder<K, V, P>
Source§impl<K, V, P> EngineConfig<K, V, P> for BlockEngineBuilder<K, V, P>
impl<K, V, P> EngineConfig<K, V, P> for BlockEngineBuilder<K, V, P>
Auto Trait Implementations§
impl<K, V, P> Freeze for BlockEngineBuilder<K, V, P>
impl<K, V, P> !RefUnwindSafe for BlockEngineBuilder<K, V, P>
impl<K, V, P> Send for BlockEngineBuilder<K, V, P>
impl<K, V, P> Sync for BlockEngineBuilder<K, V, P>
impl<K, V, P> Unpin for BlockEngineBuilder<K, V, P>
impl<K, V, P> !UnwindSafe for BlockEngineBuilder<K, V, P>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more