DataCache

Trait DataCache 

Source
pub trait DataCache {
    // Required methods
    fn get_block<'life0, 'life1, 'async_trait>(
        &'life0 self,
        cache_key: &'life1 ObjectId,
        block_idx: BlockIndex,
        block_offset: u64,
        object_size: usize,
    ) -> Pin<Box<dyn Future<Output = DataCacheResult<Option<ChecksummedBytes>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn put_block<'life0, 'async_trait>(
        &'life0 self,
        cache_key: ObjectId,
        block_idx: BlockIndex,
        block_offset: u64,
        bytes: ChecksummedBytes,
        object_size: usize,
    ) -> Pin<Box<dyn Future<Output = DataCacheResult<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn block_size(&self) -> u64;
}
Expand description

Data cache for fixed-size checksummed buffers.

TODO: Deletion and eviction of cache entries. TODO: Some version information (ETag) independent from ObjectId to allow smarter eviction?

Required Methods§

Source

fn get_block<'life0, 'life1, 'async_trait>( &'life0 self, cache_key: &'life1 ObjectId, block_idx: BlockIndex, block_offset: u64, object_size: usize, ) -> Pin<Box<dyn Future<Output = DataCacheResult<Option<ChecksummedBytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get block of data from the cache for the given ObjectId and BlockIndex, if available.

Operation may fail due to errors, or return None if the block was not available in the cache.

Source

fn put_block<'life0, 'async_trait>( &'life0 self, cache_key: ObjectId, block_idx: BlockIndex, block_offset: u64, bytes: ChecksummedBytes, object_size: usize, ) -> Pin<Box<dyn Future<Output = DataCacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Put block of data to the cache for the given ObjectId and BlockIndex.

Source

fn block_size(&self) -> u64

Returns the block size for the data cache.

Implementors§

Source§

impl DataCache for DiskDataCache

Source§

impl DataCache for InMemoryDataCache

Source§

impl<Client> DataCache for ExpressDataCache<Client>
where Client: ObjectClient + Send + Sync + 'static,

Source§

impl<DiskCache, ExpressCache> DataCache for MultilevelDataCache<DiskCache, ExpressCache>
where DiskCache: DataCache + Sync + Send + 'static, ExpressCache: DataCache + Sync,