pub struct CacheLayerBuilder<B> { /* private fields */ }Expand description
Builder for configuring CacheLayer instances.
Implementations§
Source§impl<B> CacheLayerBuilder<B>where
B: CacheBackend,
impl<B> CacheLayerBuilder<B>where
B: CacheBackend,
pub fn new(backend: B) -> Self
Sourcepub fn policy(self, policy: CachePolicy) -> Self
pub fn policy(self, policy: CachePolicy) -> Self
Replaces the cache policy with a pre-built value.
Sourcepub fn negative_ttl(self, ttl: Duration) -> Self
pub fn negative_ttl(self, ttl: Duration) -> Self
Sets the cache TTL for negative (4xx) responses.
pub fn stale_while_revalidate(self, duration: Duration) -> Self
pub fn refresh_before(self, duration: Duration) -> Self
pub fn max_body_size(self, size: Option<usize>) -> Self
pub fn min_body_size(self, size: Option<usize>) -> Self
pub fn allow_streaming_bodies(self, allow: bool) -> Self
pub fn compression(self, config: CompressionConfig) -> Self
pub fn respect_cache_control(self, enabled: bool) -> Self
pub fn statuses(self, statuses: impl IntoIterator<Item = u16>) -> Self
pub fn method_predicate<F>(self, predicate: F) -> Self
pub fn header_allowlist<I, S>(self, headers: I) -> Self
pub fn key_extractor(self, extractor: KeyExtractor) -> Self
Sourcepub fn auto_refresh(self, config: AutoRefreshConfig) -> Self
pub fn auto_refresh(self, config: AutoRefreshConfig) -> Self
Enables auto-refresh functionality with the provided configuration.
When enabled, frequently accessed cache entries will be proactively refreshed before they expire, reducing cache misses and latency.
pub fn build(self) -> CacheLayer<B>
Auto Trait Implementations§
impl<B> Freeze for CacheLayerBuilder<B>where
B: Freeze,
impl<B> !RefUnwindSafe for CacheLayerBuilder<B>
impl<B> Send for CacheLayerBuilder<B>where
B: Send,
impl<B> Sync for CacheLayerBuilder<B>where
B: Sync,
impl<B> Unpin for CacheLayerBuilder<B>where
B: Unpin,
impl<B> !UnwindSafe for CacheLayerBuilder<B>
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