pub struct CacheManager { /* private fields */ }Expand description
Cache manager for model storage
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new(config: CacheConfig) -> Self
pub fn new(config: CacheConfig) -> Self
Create a new cache manager
Sourcepub fn with_policy(self, policy: EvictionPolicy) -> Self
pub fn with_policy(self, policy: EvictionPolicy) -> Self
Set eviction policy
Sourcepub fn config(&self) -> &CacheConfig
pub fn config(&self) -> &CacheConfig
Get configuration
Sourcepub fn add(&mut self, entry: CacheEntry)
pub fn add(&mut self, entry: CacheEntry)
Add an entry to the cache
Sourcepub fn get(&mut self, name: &str, version: &str) -> Option<&CacheEntry>
pub fn get(&mut self, name: &str, version: &str) -> Option<&CacheEntry>
Get an entry from the cache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Sourcepub fn needs_cleanup(&self) -> bool
pub fn needs_cleanup(&self) -> bool
Check if cleanup is needed
Sourcepub fn cleanup_to_target(&mut self) -> u64
pub fn cleanup_to_target(&mut self) -> u64
Cleanup old/unused entries to reach target
Returns bytes freed
Sourcepub fn cleanup_to_size(&mut self, target_bytes: u64) -> u64
pub fn cleanup_to_size(&mut self, target_bytes: u64) -> u64
Cleanup to reach a specific size
Returns bytes freed
Sourcepub fn cleanup_old_entries(&mut self) -> u64
pub fn cleanup_old_entries(&mut self) -> u64
Remove entries older than max age
Returns bytes freed
Sourcepub fn list(&self) -> Vec<&CacheEntry>
pub fn list(&self) -> Vec<&CacheEntry>
List all entries
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CacheManager
impl RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnsafeUnpin for CacheManager
impl UnwindSafe for CacheManager
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