Trait pingora_cache::storage::Storage

source ·
pub trait Storage {
    // Required methods
    fn lookup<'life0, 'life1, 'async_trait>(
        &'static self,
        key: &'life0 CacheKey,
        trace: &'life1 SpanHandle
    ) -> Pin<Box<dyn Future<Output = Result<Option<(CacheMeta, HitHandler)>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_miss_handler<'life0, 'life1, 'life2, 'async_trait>(
        &'static self,
        key: &'life0 CacheKey,
        meta: &'life1 CacheMeta,
        trace: &'life2 SpanHandle
    ) -> Pin<Box<dyn Future<Output = Result<MissHandler>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn purge<'life0, 'life1, 'async_trait>(
        &'static self,
        key: &'life0 CompactCacheKey,
        trace: &'life1 SpanHandle
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn update_meta<'life0, 'life1, 'life2, 'async_trait>(
        &'static self,
        key: &'life0 CacheKey,
        meta: &'life1 CacheMeta,
        trace: &'life2 SpanHandle
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn as_any(&self) -> &(dyn Any + Send + Sync + 'static);

    // Provided method
    fn support_streaming_partial_write(&self) -> bool { ... }
}
Expand description

Cache storage interface

Required Methods§

source

fn lookup<'life0, 'life1, 'async_trait>( &'static self, key: &'life0 CacheKey, trace: &'life1 SpanHandle ) -> Pin<Box<dyn Future<Output = Result<Option<(CacheMeta, HitHandler)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Lookup the storage for the given CacheKey

source

fn get_miss_handler<'life0, 'life1, 'life2, 'async_trait>( &'static self, key: &'life0 CacheKey, meta: &'life1 CacheMeta, trace: &'life2 SpanHandle ) -> Pin<Box<dyn Future<Output = Result<MissHandler>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Write the given CacheMeta to the storage. Return MissHandler to write the body later.

source

fn purge<'life0, 'life1, 'async_trait>( &'static self, key: &'life0 CompactCacheKey, trace: &'life1 SpanHandle ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Delete the cached asset for the given key

CompactCacheKey is used here because it is how eviction managers store the keys

source

fn update_meta<'life0, 'life1, 'life2, 'async_trait>( &'static self, key: &'life0 CacheKey, meta: &'life1 CacheMeta, trace: &'life2 SpanHandle ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Update cache header and metadata for the already stored asset.

source

fn as_any(&self) -> &(dyn Any + Send + Sync + 'static)

Helper function to cast the trait object to concrete types

Provided Methods§

source

fn support_streaming_partial_write(&self) -> bool

Whether this storage backend supports reading partially written data

This is to indicate when cache should unlock readers

Implementors§