pub struct SmartCache<K, V>{ /* private fields */ }Expand description
LRU cache implementation with advanced features
Implementations§
Source§impl<K, V> SmartCache<K, V>
impl<K, V> SmartCache<K, V>
Sourcepub fn new(max_size: usize, policy: EvictionPolicy) -> Self
pub fn new(max_size: usize, policy: EvictionPolicy) -> Self
Create a new smart cache with specified capacity and policy
Sourcepub fn with_ttl(max_size: usize, policy: EvictionPolicy, ttl: Duration) -> Self
pub fn with_ttl(max_size: usize, policy: EvictionPolicy, ttl: Duration) -> Self
Create cache with time-to-live
Sourcepub fn insert_with_ttl(&mut self, key: K, value: V, ttl: Option<Duration>)
pub fn insert_with_ttl(&mut self, key: K, value: V, ttl: Option<Duration>)
Insert value with custom TTL
Sourcepub fn stats(&self) -> &CacheStatistics
pub fn stats(&self) -> &CacheStatistics
Get cache statistics
Sourcepub fn cleanup_expired(&mut self)
pub fn cleanup_expired(&mut self)
Clean expired entries
Trait Implementations§
Auto Trait Implementations§
impl<K, V> Freeze for SmartCache<K, V>
impl<K, V> RefUnwindSafe for SmartCache<K, V>
impl<K, V> Send for SmartCache<K, V>
impl<K, V> Sync for SmartCache<K, V>
impl<K, V> Unpin for SmartCache<K, V>
impl<K, V> UnsafeUnpin for SmartCache<K, V>
impl<K, V> UnwindSafe for SmartCache<K, V>
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,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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