pub struct EvalCache { /* private fields */ }Expand description
Content-addressed evaluation cache.
In-memory HashMap backed by optional persistent JSON file.
Implementations§
Source§impl EvalCache
impl EvalCache
Sourcepub fn new(persist: bool) -> Self
pub fn new(persist: bool) -> Self
Create a new cache. If persist is true, loads/saves to
~/.cache/sui/eval-cache.json.
Sourcepub fn with_path(path: PathBuf) -> Self
pub fn with_path(path: PathBuf) -> Self
Create a cache with a custom database path (for testing).
Sourcepub fn key_for_file(
path: &Path,
lock_path: Option<&Path>,
) -> Result<CacheKey, CacheError>
pub fn key_for_file( path: &Path, lock_path: Option<&Path>, ) -> Result<CacheKey, CacheError>
Compute a cache key for a file on disk.
§Errors
Returns CacheError::Io if the file (or lock file) cannot be read.
Sourcepub fn key_for_expr(expr: &str) -> CacheKey
pub fn key_for_expr(expr: &str) -> CacheKey
Compute a cache key from a string expression.
Sourcepub fn get(&self, key: &CacheKey) -> Option<&CachedValue>
pub fn get(&self, key: &CacheKey) -> Option<&CachedValue>
Look up a cached value.
Sourcepub fn put(&mut self, key: CacheKey, value: CachedValue)
pub fn put(&mut self, key: CacheKey, value: CachedValue)
Store a value in the cache.
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 UnsafeUnpin 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