pub struct ArtifactCache { /* private fields */ }Expand description
In-memory artifact cache with LRU eviction.
Implementations§
Source§impl ArtifactCache
impl ArtifactCache
pub fn new(max_size_bytes: u64) -> Self
Sourcepub fn get(&mut self, key: &CacheKey, now: f64) -> Option<&CacheEntry>
pub fn get(&mut self, key: &CacheKey, now: f64) -> Option<&CacheEntry>
Look up an artifact by cache key.
Sourcepub fn insert(&mut self, entry: CacheEntry)
pub fn insert(&mut self, entry: CacheEntry)
Insert an artifact into the cache. Evicts oldest entries if needed.
Sourcepub fn remove(&mut self, key: &CacheKey) -> Option<CacheEntry>
pub fn remove(&mut self, key: &CacheKey) -> Option<CacheEntry>
Remove an entry by key.
Sourcepub fn purge_expired(&mut self, now: f64) -> usize
pub fn purge_expired(&mut self, now: f64) -> usize
Remove all expired entries.
Sourcepub fn size_bytes(&self) -> u64
pub fn size_bytes(&self) -> u64
Current cache size in bytes.
Sourcepub fn utilization(&self) -> f64
pub fn utilization(&self) -> f64
Cache utilization as a fraction (0.0 – 1.0).
Auto Trait Implementations§
impl Freeze for ArtifactCache
impl RefUnwindSafe for ArtifactCache
impl Send for ArtifactCache
impl Sync for ArtifactCache
impl Unpin for ArtifactCache
impl UnsafeUnpin for ArtifactCache
impl UnwindSafe for ArtifactCache
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