HttpCache

Trait HttpCache 

Source
pub trait HttpCache:
    Send
    + Sync
    + Any {
    // Required methods
    fn policy(
        &'static self,
        key: CacheKey,
    ) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send>>;
    fn set_policy(
        &'static self,
        key: CacheKey,
        policy: CachePolicy,
    ) -> Pin<Box<dyn Future<Output = bool> + Send>>;
    fn body(
        &'static self,
        key: CacheKey,
    ) -> Pin<Box<dyn Future<Output = Option<IpcBytes>> + Send>>;
    fn set(
        &'static self,
        key: CacheKey,
        policy: CachePolicy,
        body: IpcBytes,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn remove(
        &'static self,
        key: CacheKey,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn cookie(
        &'static self,
        uri: Uri,
    ) -> Pin<Box<dyn Future<Output = Option<HeaderValue>> + Send>>;
    fn set_cookie(
        &'static self,
        uri: Uri,
        cookie: HeaderValue,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn remove_cookie(
        &'static self,
        uri: Uri,
    ) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn purge(&'static self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
    fn prune(&'static self) -> Pin<Box<dyn Future<Output = ()> + Send>>;
}
Expand description

HTTP cache backend.

Cache implementers must store a CachePolicy and IpcBytes body for a given CacheKey.

Required Methods§

Source

fn policy( &'static self, key: CacheKey, ) -> Pin<Box<dyn Future<Output = Option<CachePolicy>> + Send>>

Get the cache-policy for the given key.

Source

fn set_policy( &'static self, key: CacheKey, policy: CachePolicy, ) -> Pin<Box<dyn Future<Output = bool> + Send>>

Replaces the cache-policy for the given key.

Returns false if the entry does not exist.

Source

fn body( &'static self, key: CacheKey, ) -> Pin<Box<dyn Future<Output = Option<IpcBytes>> + Send>>

Get the cached body for the given key.

Source

fn set( &'static self, key: CacheKey, policy: CachePolicy, body: IpcBytes, ) -> Pin<Box<dyn Future<Output = ()> + Send>>

Caches the policy and body for the given key.

Source

fn remove( &'static self, key: CacheKey, ) -> Pin<Box<dyn Future<Output = ()> + Send>>

Remove cache policy and body for the given key.

Source

fn cookie( &'static self, uri: Uri, ) -> Pin<Box<dyn Future<Output = Option<HeaderValue>> + Send>>

Get the Cookie value associated with the uri.

The returned value is validated and ready for sending.

Store the Set-Cookie value associated with the uri.

The uri and cookie must be directly from the response, the cache will parse and property associate the cookie with domain.

Remove the Cookie value associated with the uri.

Source

fn purge(&'static self) -> Pin<Box<dyn Future<Output = ()> + Send>>

Remove all cached entries that are not locked in a set* operation.

Source

fn prune(&'static self) -> Pin<Box<dyn Future<Output = ()> + Send>>

Remove cache entries to reduce pressure.

What entries are removed depends on the cache DB implementer.

Implementors§