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);
fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync);
// Provided methods
fn can_seek(&self) -> bool { ... }
fn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()> { ... }
fn should_count_access(&self) -> bool { ... }
fn get_eviction_weight(&self) -> usize { ... }
}Expand description
Cache hit handling trait
Required Methods§
Sourcefn 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 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.
Sourcefn 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 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
Sourcefn as_any(&self) -> &(dyn Any + Send + Sync)
fn as_any(&self) -> &(dyn Any + Send + Sync)
Helper function to cast the trait object to concrete types
Sourcefn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync)
fn as_any_mut(&mut self) -> &mut (dyn Any + Send + Sync)
Helper function to cast the trait object to concrete types
Provided Methods§
Sourcefn seek(&mut self, _start: usize, _end: Option<usize>) -> Result<()>
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.
Sourcefn should_count_access(&self) -> bool
fn should_count_access(&self) -> bool
Should we count this hit handler instance as an access in the eviction manager.
Defaults to returning true to track all cache hits as accesses. Customize this if certain hits should not affect the eviction system’s view of the asset.
Sourcefn get_eviction_weight(&self) -> usize
fn get_eviction_weight(&self) -> usize
Returns the weight of the current cache hit asset to report to the eviction manager.
This allows the eviction system to initialize a weight for the asset, in case it is not already tracking it (e.g. storage is out of sync with the eviction manager).
Defaults to 0.