Skip to main content

CacheableRequest

Trait CacheableRequest 

Source
pub trait CacheableRequest: Sized {
    // Required method
    fn cache_policy<P, E>(
        self,
        predicates: P,
        extractors: E,
    ) -> impl Future<Output = RequestCachePolicy<Self>> + Send
       where P: Predicate<Subject = Self> + Send + Sync,
             E: Extractor<Subject = Self> + Send + Sync;
}
Expand description

Trait for request types that can participate in caching.

Implementations determine whether a request should be cached by applying predicates and extracting cache keys.

§Type Requirements

Request types must be Sized to allow ownership transfer through the caching pipeline.

§Processing

The cache_policy method:

  1. Applies predicates to determine if the request is cacheable
  2. If cacheable, extracts a cache key using the provided extractors
  3. Returns either Cacheable with the key or NonCacheable

Required Methods§

Source

fn cache_policy<P, E>( self, predicates: P, extractors: E, ) -> impl Future<Output = RequestCachePolicy<Self>> + Send
where P: Predicate<Subject = Self> + Send + Sync, E: Extractor<Subject = Self> + Send + Sync,

Determine if this request should be cached and extract its key.

§Arguments
  • predicates - Predicates to evaluate whether the request is cacheable
  • extractors - Extractors to generate the cache key

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§