Skip to main content

CacheConfig

Trait CacheConfig 

Source
pub trait CacheConfig<Req, Res> {
    type RequestPredicate: Predicate<Subject = Req> + Send + Sync + 'static;
    type ResponsePredicate: Predicate<Subject = Res> + Send + Sync + 'static;
    type Extractor: Extractor<Subject = Req> + Send + Sync + 'static;

    // Required methods
    fn request_predicates(&self) -> Self::RequestPredicate;
    fn response_predicates(&self) -> Self::ResponsePredicate;
    fn extractors(&self) -> Self::Extractor;
    fn policy(&self) -> &PolicyConfig;
}
Expand description

Trait for cache configuration.

Provides predicates for determining cacheability, extractors for generating cache keys, and policy for TTL/staleness behavior.

Required Associated Types§

Source

type RequestPredicate: Predicate<Subject = Req> + Send + Sync + 'static

Predicate type for filtering requests.

Source

type ResponsePredicate: Predicate<Subject = Res> + Send + Sync + 'static

Predicate type for filtering responses.

Source

type Extractor: Extractor<Subject = Req> + Send + Sync + 'static

Extractor type for generating cache keys.

Required Methods§

Source

fn request_predicates(&self) -> Self::RequestPredicate

Returns predicates that decide if a request should be cached.

Source

fn response_predicates(&self) -> Self::ResponsePredicate

Returns predicates that decide if a response should be cached.

Source

fn extractors(&self) -> Self::Extractor

Returns extractors that generate cache keys from requests.

Source

fn policy(&self) -> &PolicyConfig

Returns TTL and behavior policy for cached entries.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T, Req, Res> CacheConfig<Req, Res> for Arc<T>
where T: CacheConfig<Req, Res>,

Implementors§

Source§

impl<Req, Res, ReqPred, ResPred, Ext> CacheConfig<Req, Res> for Config<ReqPred, ResPred, Ext>
where Req: Send, Res: Send, ReqPred: Predicate<Subject = Req> + Send + Sync + 'static, ResPred: Predicate<Subject = Res> + Send + Sync + 'static, Ext: Extractor<Subject = Req> + Send + Sync + 'static,