pub struct Cache<S, Req, K, Resp> { /* private fields */ }Expand description
A Tower Service that caches responses.
This service wraps an inner service and caches successful responses. When a request comes in, the cache checks if a valid cached response exists. If so, it returns the cached value immediately without calling the inner service.
Responses must implement Clone to be cacheable.
Implementations§
Trait Implementations§
Source§impl<S, Req, K> Service<Req> for Cache<S, Req, K, S::Response>
impl<S, Req, K> Service<Req> for Cache<S, Req, K, S::Response>
Source§type Future = Pin<Box<dyn Future<Output = Result<<Cache<S, Req, K, <S as Service<Req>>::Response> as Service<Req>>::Response, <Cache<S, Req, K, <S as Service<Req>>::Response> as Service<Req>>::Error>> + Send>>
type Future = Pin<Box<dyn Future<Output = Result<<Cache<S, Req, K, <S as Service<Req>>::Response> as Service<Req>>::Response, <Cache<S, Req, K, <S as Service<Req>>::Response> as Service<Req>>::Error>> + Send>>
The future response value.
Auto Trait Implementations§
impl<S, Req, K, Resp> Freeze for Cache<S, Req, K, Resp>where
S: Freeze,
impl<S, Req, K, Resp> !RefUnwindSafe for Cache<S, Req, K, Resp>
impl<S, Req, K, Resp> Send for Cache<S, Req, K, Resp>
impl<S, Req, K, Resp> Sync for Cache<S, Req, K, Resp>
impl<S, Req, K, Resp> Unpin for Cache<S, Req, K, Resp>where
S: Unpin,
impl<S, Req, K, Resp> !UnwindSafe for Cache<S, Req, K, Resp>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more