pub trait StreamingCacheManager:
Send
+ Sync
+ 'static {
type Body: Body + Send + 'static;
// Required methods
fn get(
&self,
cache_key: &str,
) -> impl Future<Output = Result<Option<(Response<Self::Body>, CachePolicy)>>> + Send
where <Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
fn put<B>(
&self,
cache_key: String,
response: Response<B>,
policy: CachePolicy,
request_url: Url,
metadata: Option<Vec<u8>>,
) -> impl Future<Output = Result<Response<Self::Body>>> + Send
where B: Body + Send + 'static,
B::Data: Send,
B::Error: Into<StreamingError>,
<Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
fn convert_body<B>(
&self,
response: Response<B>,
) -> impl Future<Output = Result<Response<Self::Body>>> + Send
where B: Body + Send + 'static,
B::Data: Send,
B::Error: Into<StreamingError>,
<Self::Body as Body>::Data: Send,
<Self::Body as Body>::Error: Into<StreamingError> + Send + Sync + 'static;
fn delete(&self, cache_key: &str) -> impl Future<Output = Result<()>> + Send;
fn empty_body(&self) -> Self::Body;
}Expand description
A streaming cache manager that supports streaming request/response bodies without buffering them in memory. This is ideal for large responses.
Required Associated Types§
Required Methods§
Sourcefn get(
&self,
cache_key: &str,
) -> impl Future<Output = Result<Option<(Response<Self::Body>, CachePolicy)>>> + Send
fn get( &self, cache_key: &str, ) -> impl Future<Output = Result<Option<(Response<Self::Body>, CachePolicy)>>> + Send
Attempts to pull a cached response and related policy from cache with streaming body.
Sourcefn put<B>(
&self,
cache_key: String,
response: Response<B>,
policy: CachePolicy,
request_url: Url,
metadata: Option<Vec<u8>>,
) -> impl Future<Output = Result<Response<Self::Body>>> + Send
fn put<B>( &self, cache_key: String, response: Response<B>, policy: CachePolicy, request_url: Url, metadata: Option<Vec<u8>>, ) -> impl Future<Output = Result<Response<Self::Body>>> + Send
Attempts to cache a response with a streaming body and related policy.
Sourcefn convert_body<B>(
&self,
response: Response<B>,
) -> impl Future<Output = Result<Response<Self::Body>>> + Send
fn convert_body<B>( &self, response: Response<B>, ) -> impl Future<Output = Result<Response<Self::Body>>> + Send
Converts a generic body to the manager’s body type for non-cacheable responses. This is called when a response should not be cached but still needs to be returned with the correct body type.
Sourcefn delete(&self, cache_key: &str) -> impl Future<Output = Result<()>> + Send
fn delete(&self, cache_key: &str) -> impl Future<Output = Result<()>> + Send
Attempts to remove a record from cache.
Sourcefn empty_body(&self) -> Self::Body
fn empty_body(&self) -> Self::Body
Creates an empty body of the manager’s body type. Used for returning 504 Gateway Timeout responses on OnlyIfCached cache misses.
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.