Skip to main content

CacheStrategy

Trait CacheStrategy 

Source
pub trait CacheStrategy<B> {
    // Required method
    fn computed_key(&self, req: &Request<B>) -> (Duration, Key);

    // Provided method
    fn ttl(&self) -> Duration { ... }
}
Expand description

Trait used for extensible definition of caching strategies for the middleware

Required Methods§

Source

fn computed_key(&self, req: &Request<B>) -> (Duration, Key)

Compute the key for caching.

This function will receive the Request sent into the handler so that it may use attributes of the incoming request for caching

Provided Methods§

Source

fn ttl(&self) -> Duration

The default time to live for all cached entries

This can be overridden by different strategies but defaults to 1 day

Implementors§