pingora_cache::predictor

Trait CacheablePredictor

Source
pub trait CacheablePredictor {
    // Required methods
    fn cacheable_prediction(&self, key: &CacheKey) -> bool;
    fn mark_cacheable(&self, key: &CacheKey) -> bool;
    fn mark_uncacheable(
        &self,
        key: &CacheKey,
        reason: NoCacheReason,
    ) -> Option<bool>;
}
Expand description

The cache predictor trait.

This trait allows user defined predictor to replace Predictor.

Required Methods§

Source

fn cacheable_prediction(&self, key: &CacheKey) -> bool

Return true if likely cacheable, false if likely not.

Source

fn mark_cacheable(&self, key: &CacheKey) -> bool

Mark cacheable to allow next request to cache. Returns false if the key was already marked cacheable.

Source

fn mark_uncacheable( &self, key: &CacheKey, reason: NoCacheReason, ) -> Option<bool>

Mark uncacheable to actively bypass cache on the next request. May skip marking on certain NoCacheReasons. Returns None if we skipped marking uncacheable. Returns Some(false) if the key was already marked uncacheable.

Implementors§

Source§

impl<const N_SHARDS: usize> CacheablePredictor for Predictor<N_SHARDS>
where [LruShard<()>; N_SHARDS]: Default,