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>;
// Provided method
fn predicted_uncacheable_reason(
&self,
_key: &CacheKey,
) -> Option<NoCacheReason> { ... }
}Expand description
The cache predictor trait.
This trait allows user defined predictor to replace Predictor.
Required Methods§
Sourcefn cacheable_prediction(&self, key: &CacheKey) -> bool
fn cacheable_prediction(&self, key: &CacheKey) -> bool
Return true if likely cacheable, false if likely not.
Sourcefn mark_cacheable(&self, key: &CacheKey) -> bool
fn mark_cacheable(&self, key: &CacheKey) -> bool
Mark cacheable to allow next request to cache. Returns false if the key was already marked cacheable.
Sourcefn mark_uncacheable(
&self,
key: &CacheKey,
reason: NoCacheReason,
) -> Option<bool>
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.
Provided Methods§
Sourcefn predicted_uncacheable_reason(&self, _key: &CacheKey) -> Option<NoCacheReason>
fn predicted_uncacheable_reason(&self, _key: &CacheKey) -> Option<NoCacheReason>
Return the NoCacheReason this key is currently remembered as uncacheable for.
Callers use this to report why a request bypassed the cache instead of inferring it.
None means the key is not remembered as uncacheable, or the implementation does not
track reasons, so callers must not assume anything about the previous response.
The default implementation returns None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".