pub struct BlockCacheStorage { /* private fields */ }Expand description
Block-aligned LRU cache for any random-access storage backend.
This is useful when the underlying storage is remote or has high per-request
latency. Reads are rounded out to fixed-size blocks and cached by block
number; callers still see the normal Storage::read_range interface.
Implementations§
Source§impl BlockCacheStorage
impl BlockCacheStorage
Sourcepub fn new(
inner: Arc<dyn Storage>,
block_size: usize,
max_blocks: usize,
) -> BlockCacheStorage
pub fn new( inner: Arc<dyn Storage>, block_size: usize, max_blocks: usize, ) -> BlockCacheStorage
Create a block cache around an existing storage backend.
block_size and max_blocks values of zero are normalized to 1.
Sourcepub fn with_defaults(inner: Arc<dyn Storage>) -> BlockCacheStorage
pub fn with_defaults(inner: Arc<dyn Storage>) -> BlockCacheStorage
Create a block cache with conservative defaults: 1 MiB blocks, 128 slots.
Sourcepub fn stats(&self) -> BlockCacheStats
pub fn stats(&self) -> BlockCacheStats
Return current cache statistics.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BlockCacheStorage
impl !RefUnwindSafe for BlockCacheStorage
impl Send for BlockCacheStorage
impl Sync for BlockCacheStorage
impl Unpin for BlockCacheStorage
impl UnsafeUnpin for BlockCacheStorage
impl !UnwindSafe for BlockCacheStorage
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
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>
Converts
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>
Converts
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