pub struct IndexCache {
pub stats: CacheStats,
/* private fields */
}
Expand description
Simple cache implemented with a Vec<RwLock<Block>>
, with the key determined by the position
modulo the size.
Prone to collisions.
Fields§
§stats: CacheStats
Trait Implementations§
Source§impl<E> DataBlockCache<E> for IndexCache
impl<E> DataBlockCache<E> for IndexCache
Source§fn new(
capacity_mb: u64,
block_size: u64,
_total_size: u64,
) -> Result<Self, CacheError<E>>
fn new( capacity_mb: u64, block_size: u64, _total_size: u64, ) -> Result<Self, CacheError<E>>
Create a new block cache with given maximal capacity, block size, and cumulative size of all
blocks.
Source§fn stats(&self) -> &CacheStats
fn stats(&self) -> &CacheStats
Caching statistics.
Source§fn get<'life0, 'async_trait>(
&'life0 self,
pos: u64,
) -> Pin<Box<dyn Future<Output = Option<RwLockReadGuard<'_, Block>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
pos: u64,
) -> Pin<Box<dyn Future<Output = Option<RwLockReadGuard<'_, Block>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get the block at a position.
Source§fn insert_lock<'life0, 'async_trait, A>(
&'life0 self,
pos: u64,
f: impl 'async_trait + Future<Output = Result<A, E>> + Send,
) -> Pin<Box<dyn Future<Output = Result<RwLockReadGuard<'_, Block>, CacheError<E>>> + Send + 'async_trait>>
fn insert_lock<'life0, 'async_trait, A>( &'life0 self, pos: u64, f: impl 'async_trait + Future<Output = Result<A, E>> + Send, ) -> Pin<Box<dyn Future<Output = Result<RwLockReadGuard<'_, Block>, CacheError<E>>> + Send + 'async_trait>>
Insert a block at a position, locking until the output is ready.
Source§impl Debug for IndexCache
impl Debug for IndexCache
Auto Trait Implementations§
impl !Freeze for IndexCache
impl !RefUnwindSafe for IndexCache
impl Send for IndexCache
impl Sync for IndexCache
impl Unpin for IndexCache
impl !UnwindSafe for IndexCache
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