pub struct SmartCache<T, K>{ /* private fields */ }Expand description
Smart adaptive cache with multi-tier support
Implementations§
Source§impl<T, K> SmartCache<T, K>
impl<T, K> SmartCache<T, K>
Sourcepub fn new(
l1_max_size: usize,
l2_max_size: usize,
l3_max_size: usize,
policy: EvictionPolicy,
config: CacheConfig,
) -> Self
pub fn new( l1_max_size: usize, l2_max_size: usize, l3_max_size: usize, policy: EvictionPolicy, config: CacheConfig, ) -> Self
Create a new smart cache with specified capacities
Sourcepub fn get(&self, key: &K) -> Option<(Tensor<T>, Tensor<T>)>
pub fn get(&self, key: &K) -> Option<(Tensor<T>, Tensor<T>)>
Get an item from cache (checks all levels)
Sourcepub fn put(&self, key: K, value: (Tensor<T>, Tensor<T>))
pub fn put(&self, key: K, value: (Tensor<T>, Tensor<T>))
Put an item into cache (automatically selects appropriate level)
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn cleanup_expired(&self)
pub fn cleanup_expired(&self)
Run background cleanup to remove expired entries
Auto Trait Implementations§
impl<T, K> Freeze for SmartCache<T, K>
impl<T, K> RefUnwindSafe for SmartCache<T, K>
impl<T, K> Send for SmartCache<T, K>
impl<T, K> Sync for SmartCache<T, K>
impl<T, K> Unpin for SmartCache<T, K>
impl<T, K> UnsafeUnpin for SmartCache<T, K>
impl<T, K> UnwindSafe for SmartCache<T, K>
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