pub struct CacheBuilder<B, P, CM, O> { /* private fields */ }Expand description
Builder for Cache with typestate pattern.
The builder ensures at compile time that both backend and policy are configured before the cache can be built.
Implementations§
Source§impl<P, CM, O> CacheBuilder<NoBackend, P, CM, O>
impl<P, CM, O> CacheBuilder<NoBackend, P, CM, O>
Sourcepub fn backend<B: CacheBackend>(
self,
backend: B,
) -> CacheBuilder<WithBackend<B>, P, CM, O>
pub fn backend<B: CacheBackend>( self, backend: B, ) -> CacheBuilder<WithBackend<B>, P, CM, O>
Source§impl<B, CM, O> CacheBuilder<B, NoPolicy, CM, O>
impl<B, CM, O> CacheBuilder<B, NoPolicy, CM, O>
Sourcepub fn policy(self, policy: PolicyConfig) -> CacheBuilder<B, WithPolicy, CM, O>
pub fn policy(self, policy: PolicyConfig) -> CacheBuilder<B, WithPolicy, CM, O>
Source§impl<B, P, CM, O> CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> CacheBuilder<B, P, CM, O>
Sourcepub fn concurrency_manager<CM2>(self, cm: CM2) -> CacheBuilder<B, P, CM2, O>
pub fn concurrency_manager<CM2>(self, cm: CM2) -> CacheBuilder<B, P, CM2, O>
Set the concurrency manager for dogpile prevention.
By default, NoopConcurrencyManager is used which doesn’t prevent dogpile.
Use BroadcastConcurrencyManager
for production workloads.
§Example
ⓘ
use hitbox::concurrency::BroadcastConcurrencyManager;
let cache = Cache::builder()
.backend(backend)
.policy(policy)
.concurrency_manager(BroadcastConcurrencyManager::new())
.build();Sourcepub fn offload<O2>(self, offload: O2) -> CacheBuilder<B, P, CM, O2>
pub fn offload<O2>(self, offload: O2) -> CacheBuilder<B, P, CM, O2>
Set the offload manager for background task execution.
By default, DisabledOffload is used which disables background revalidation.
Use OffloadManager to enable
Stale-While-Revalidate pattern.
§Example
ⓘ
use hitbox::offload::OffloadManager;
let cache = Cache::builder()
.backend(backend)
.policy(policy)
.offload(OffloadManager::with_defaults())
.build();Source§impl<B, CM, O> CacheBuilder<WithBackend<B>, WithPolicy, CM, O>where
B: CacheBackend,
impl<B, CM, O> CacheBuilder<WithBackend<B>, WithPolicy, CM, O>where
B: CacheBackend,
Auto Trait Implementations§
impl<B, P, CM, O> Freeze for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> RefUnwindSafe for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> Send for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> Sync for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> Unpin for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> UnsafeUnpin for CacheBuilder<B, P, CM, O>
impl<B, P, CM, O> UnwindSafe for CacheBuilder<B, P, CM, O>
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