pub struct CacheBuilder<K: KeyExtractor, B: Bypasser> { /* private fields */ }Expand description
Builds a cache using some overridable defaults
Implementations§
Source§impl<K: KeyExtractor> CacheBuilder<K, NoopBypasser>
impl<K: KeyExtractor> CacheBuilder<K, NoopBypasser>
Source§impl<K: KeyExtractor, B: Bypasser> CacheBuilder<K, B>
impl<K: KeyExtractor, B: Bypasser> CacheBuilder<K, B>
Sourcepub fn new_with_bypasser(key_extractor: K, bypasser: B) -> Self
pub fn new_with_bypasser(key_extractor: K, bypasser: B) -> Self
Create new CacheBuilder with a bypasser
Sourcepub const fn cache_size(self, v: u64) -> Self
pub const fn cache_size(self, v: u64) -> Self
Sets the cache size. Default 128MB.
Sourcepub const fn max_item_size(self, v: usize) -> Self
pub const fn max_item_size(self, v: usize) -> Self
Sets the maximum entry size. Default 16MB.
Sourcepub const fn max_ttl(self, v: Duration) -> Self
pub const fn max_ttl(self, v: Duration) -> Self
Sets the maximum cache entry TTL that can be overriden by Cache-Control header. Default 1 day.
Sourcepub const fn lock_timeout(self, v: Duration) -> Self
pub const fn lock_timeout(self, v: Duration) -> Self
Sets the cache lock timeout. Default 5 sec.
Sourcepub const fn body_timeout(self, v: Duration) -> Self
pub const fn body_timeout(self, v: Duration) -> Self
Sets the body reading timeout. Default 1 min.
Sourcepub const fn xfetch_beta(self, v: f64) -> Self
pub const fn xfetch_beta(self, v: f64) -> Self
Sets the beta term of X-Fetch algorithm. Default 0.0
Sourcepub const fn obey_cache_control(self, v: bool) -> Self
pub const fn obey_cache_control(self, v: bool) -> Self
Whether to obey Cache-Control headers in the response. Defaults to false.
Sourcepub fn build(self) -> Result<Cache<K, B>, CacheError>
pub fn build(self) -> Result<Cache<K, B>, CacheError>
Try to build the cache from this builder
Auto Trait Implementations§
impl<K, B> Freeze for CacheBuilder<K, B>
impl<K, B> !RefUnwindSafe for CacheBuilder<K, B>
impl<K, B> Send for CacheBuilder<K, B>
impl<K, B> Sync for CacheBuilder<K, B>
impl<K, B> Unpin for CacheBuilder<K, B>
impl<K, B> !UnwindSafe for CacheBuilder<K, B>
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request