pub struct AdaptiveCacheManager<K: Hash + Eq + Clone, V: Clone> { /* private fields */ }Expand description
Adaptive cache manager
Implementations§
Source§impl<K: Hash + Eq + Clone, V: Clone> AdaptiveCacheManager<K, V>
impl<K: Hash + Eq + Clone, V: Clone> AdaptiveCacheManager<K, V>
Sourcepub fn new(config: AdaptiveCacheConfig) -> Self
pub fn new(config: AdaptiveCacheConfig) -> Self
Create new adaptive cache manager
Sourcepub fn insert(&self, key: K, value: V, size_bytes: usize) -> Result<()>
pub fn insert(&self, key: K, value: V, size_bytes: usize) -> Result<()>
Insert value into cache
Sourcepub fn insert_with_priority(
&self,
key: K,
value: V,
size_bytes: usize,
priority: u32,
) -> Result<()>
pub fn insert_with_priority( &self, key: K, value: V, size_bytes: usize, priority: u32, ) -> Result<()>
Insert value with priority
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn memory_usage(&self) -> usize
pub fn memory_usage(&self) -> usize
Get current memory usage
Auto Trait Implementations§
impl<K, V> Freeze for AdaptiveCacheManager<K, V>
impl<K, V> RefUnwindSafe for AdaptiveCacheManager<K, V>where
Arc<Mutex<HashMap<K, CacheEntry<V>>>>: RefUnwindSafe,
Arc<Mutex<VecDeque<K>>>: RefUnwindSafe,
Arc<Mutex<HashMap<K, AccessPatternStats>>>: RefUnwindSafe,
impl<K, V> Send for AdaptiveCacheManager<K, V>
impl<K, V> Sync for AdaptiveCacheManager<K, V>
impl<K, V> Unpin for AdaptiveCacheManager<K, V>
impl<K, V> UnsafeUnpin for AdaptiveCacheManager<K, V>where
Arc<Mutex<HashMap<K, CacheEntry<V>>>>: UnsafeUnpin,
Arc<Mutex<VecDeque<K>>>: UnsafeUnpin,
Arc<Mutex<HashMap<K, AccessPatternStats>>>: UnsafeUnpin,
impl<K, V> UnwindSafe for AdaptiveCacheManager<K, V>where
Arc<Mutex<HashMap<K, CacheEntry<V>>>>: UnwindSafe,
Arc<Mutex<VecDeque<K>>>: UnwindSafe,
Arc<Mutex<HashMap<K, AccessPatternStats>>>: UnwindSafe,
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
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