pub struct EvalCache { /* private fields */ }Expand description
Thread-safe cache for expression evaluation results with LRU eviction.
Uses DashMap for concurrent access and FxHasher for fast hashing.
Implementations§
Source§impl EvalCache
impl EvalCache
Sourcepub fn with_capacity(max_size: usize) -> Self
pub fn with_capacity(max_size: usize) -> Self
Create a new evaluation cache with specified maximum size
Sourcepub fn get_or_compute<F>(
&self,
expr_hash: u64,
params_hash: u64,
compute: F,
) -> f64
pub fn get_or_compute<F>( &self, expr_hash: u64, params_hash: u64, compute: F, ) -> f64
Get or compute an evaluation result
Sourcepub fn get(&self, expr_hash: u64, params_hash: u64) -> Option<f64>
pub fn get(&self, expr_hash: u64, params_hash: u64) -> Option<f64>
Try to get a cached value without computing
Sourcepub fn get_or_try_compute<F, E>(
&self,
expr_hash: u64,
params_hash: u64,
compute: F,
) -> Result<f64, E>
pub fn get_or_try_compute<F, E>( &self, expr_hash: u64, params_hash: u64, compute: F, ) -> Result<f64, E>
Get or compute with Result return type
Sourcepub fn insert(&self, expr_hash: u64, params_hash: u64, value: f64)
pub fn insert(&self, expr_hash: u64, params_hash: u64, value: f64)
Insert a value into the cache
Sourcepub fn stats(&self) -> CacheStats
pub fn stats(&self) -> CacheStats
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for EvalCache
impl !RefUnwindSafe for EvalCache
impl Send for EvalCache
impl Sync for EvalCache
impl Unpin for EvalCache
impl UnwindSafe for EvalCache
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> 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