pub struct ResultCache {
pub capacity: usize,
pub current_version: u64,
/* private fields */
}Expand description
LRU cache for expensive simulation results.
Evicts least-recently-used entries when the capacity limit is reached. Invalidation is by version number: entries with a stale version are evicted.
Fields§
§capacity: usizeMaximum number of entries.
current_version: u64Current cache version; entries below this are invalid.
Implementations§
Source§impl ResultCache
impl ResultCache
Sourcepub fn put(&mut self, entry: CacheEntry)
pub fn put(&mut self, entry: CacheEntry)
Insert or update a cache entry. Evicts LRU entry when over capacity.
Sourcepub fn get(&mut self, key: &str) -> Option<&CacheEntry>
pub fn get(&mut self, key: &str) -> Option<&CacheEntry>
Retrieve a cached entry by key, moving it to the front (MRU).
Returns None if the key is not found or the entry is stale.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
Increment the version, invalidating all current cache entries.
Sourcepub fn evict_stale(&mut self)
pub fn evict_stale(&mut self)
Evict all stale entries (version < current_version).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ResultCache
impl RefUnwindSafe for ResultCache
impl Send for ResultCache
impl Sync for ResultCache
impl Unpin for ResultCache
impl UnsafeUnpin for ResultCache
impl UnwindSafe for ResultCache
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<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.