pub struct CacheManager { /* private fields */ }Expand description
Manages multiple cached model files with LRU eviction.
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new(cache_dir: impl Into<String>, max_size_bytes: usize) -> Self
pub fn new(cache_dir: impl Into<String>, max_size_bytes: usize) -> Self
Create a new manager for the given directory with a byte budget.
Sourcepub fn register(&mut self, info: CacheFileInfo)
pub fn register(&mut self, info: CacheFileInfo)
Register a cached file.
Sourcepub fn total_used_bytes(&self) -> usize
pub fn total_used_bytes(&self) -> usize
Total bytes used by all registered cache files.
Sourcepub fn should_evict(&self) -> bool
pub fn should_evict(&self) -> bool
Whether total usage exceeds the budget.
Sourcepub fn eviction_candidates(&self) -> Vec<&CacheFileInfo>
pub fn eviction_candidates(&self) -> Vec<&CacheFileInfo>
Candidates for eviction, sorted oldest-first (LRU).
Sourcepub fn utilization(&self) -> f32
pub fn utilization(&self) -> f32
Fraction of budget used (0.0 – 1.0+).
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
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