pingora_cache::storage

Trait HandleHit

Source
pub trait HandleHit {
    // Required methods
    fn read_body<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn finish<'life0, 'life1, 'async_trait>(
        self: Box<Self>,
        storage: &'static (dyn Storage + Sync),
        key: &'life0 CacheKey,
        trace: &'life1 SpanHandle,
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn as_any(&self) -> &(dyn Any + Send + Sync);

    // Provided methods
    fn can_seek(&self) -> bool { ... }
    fn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()> { ... }
}
Expand description

Cache hit handling trait

Required Methods§

Source

fn read_body<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Read cached body

Return None when no more body to read.

Source

fn finish<'life0, 'life1, 'async_trait>( self: Box<Self>, storage: &'static (dyn Storage + Sync), key: &'life0 CacheKey, trace: &'life1 SpanHandle, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Finish the current cache hit

Source

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

Helper function to cast the trait object to concrete types

Provided Methods§

Source

fn can_seek(&self) -> bool

Whether this storage allow seeking to a certain range of body

Source

fn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()>

Try to seek to a certain range of the body

end: None means to read to the end of the body.

Implementors§