pub struct TensorCache<T> { /* private fields */ }Expand description
Tensor cache with configurable eviction policy
Implementations§
Source§impl<T: Clone> TensorCache<T>
impl<T: Clone> TensorCache<T>
pub fn new(eviction_policy: EvictionPolicy) -> Self
pub fn with_max_size(self, max_entries: usize) -> Self
pub fn with_max_bytes(self, max_bytes: usize) -> Self
Sourcepub fn insert(&mut self, key: CacheKey, value: T, size_bytes: usize)
pub fn insert(&mut self, key: CacheKey, value: T, size_bytes: usize)
Insert a value into the cache
Sourcepub fn contains(&self, key: &CacheKey) -> bool
pub fn contains(&self, key: &CacheKey) -> bool
Check if a key exists in the cache without updating access stats
Sourcepub fn stats(&self) -> &CacheStats
pub fn stats(&self) -> &CacheStats
Get cache statistics
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset statistics (keep cached entries)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TensorCache<T>
impl<T> RefUnwindSafe for TensorCache<T>where
T: RefUnwindSafe,
impl<T> Send for TensorCache<T>where
T: Send,
impl<T> Sync for TensorCache<T>where
T: Sync,
impl<T> Unpin for TensorCache<T>where
T: Unpin,
impl<T> UnwindSafe for TensorCache<T>where
T: 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