pub struct CacheBuilder<K, V, S, M>{ /* private fields */ }Expand description
In-memory cache builder.
Implementations§
Source§impl<K, V> CacheBuilder<K, V, RandomState, NoopMetricsRegistry>
impl<K, V> CacheBuilder<K, V, RandomState, NoopMetricsRegistry>
Source§impl<K, V, S, M> CacheBuilder<K, V, S, M>
impl<K, V, S, M> CacheBuilder<K, V, S, M>
Sourcepub fn with_name(self, name: impl Into<Cow<'static, str>>) -> Self
pub fn with_name(self, name: impl Into<Cow<'static, str>>) -> Self
Set the name of the foyer in-memory cache instance.
foyer will use the name as the prefix of the metric names.
Default: foyer.
Sourcepub fn with_shards(self, shards: usize) -> Self
pub fn with_shards(self, shards: usize) -> Self
Set in-memory cache sharding count. Entries will be distributed to different shards based on their hash. Operations on different shard can be parallelized.
Sourcepub fn with_eviction_config(
self,
eviction_config: impl Into<EvictionConfig>,
) -> Self
pub fn with_eviction_config( self, eviction_config: impl Into<EvictionConfig>, ) -> Self
Set in-memory cache eviction algorithm.
The default value is a general-used w-TinyLFU algorithm.
Sourcepub fn with_hash_builder<OS>(
self,
hash_builder: OS,
) -> CacheBuilder<K, V, OS, M>where
OS: HashBuilder,
pub fn with_hash_builder<OS>(
self,
hash_builder: OS,
) -> CacheBuilder<K, V, OS, M>where
OS: HashBuilder,
Set in-memory cache hash builder.
Sourcepub fn with_weighter(self, weighter: impl Weighter<K, V>) -> Self
pub fn with_weighter(self, weighter: impl Weighter<K, V>) -> Self
Set in-memory cache weighter.
Sourcepub fn with_event_listener(
self,
event_listener: Arc<dyn EventListener<Key = K, Value = V>>,
) -> Self
pub fn with_event_listener( self, event_listener: Arc<dyn EventListener<Key = K, Value = V>>, ) -> Self
Set event listener.
Sourcepub fn with_metrics_registry<OM>(
self,
registry: OM,
) -> CacheBuilder<K, V, S, OM>where
OM: RegistryOps,
pub fn with_metrics_registry<OM>(
self,
registry: OM,
) -> CacheBuilder<K, V, S, OM>where
OM: RegistryOps,
Set metrics registry.
Default: NoopMetricsRegistry.
Sourcepub fn build(self) -> Cache<K, V, S>where
M: RegistryOps,
pub fn build(self) -> Cache<K, V, S>where
M: RegistryOps,
Build in-memory cache with the given configuration.
Auto Trait Implementations§
impl<K, V, S, M> Freeze for CacheBuilder<K, V, S, M>
impl<K, V, S, M> !RefUnwindSafe for CacheBuilder<K, V, S, M>
impl<K, V, S, M> Send for CacheBuilder<K, V, S, M>where
M: Send,
impl<K, V, S, M> Sync for CacheBuilder<K, V, S, M>where
M: Sync,
impl<K, V, S, M> Unpin for CacheBuilder<K, V, S, M>
impl<K, V, S, M> !UnwindSafe for CacheBuilder<K, V, S, M>
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
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 more