pub struct EvalCache { /* private fields */ }Expand description
Content-addressed evaluation cache with optional persistence.
Implementations§
Source§impl EvalCache
impl EvalCache
Sourcepub fn with_persistent(db_path: PathBuf) -> Self
pub fn with_persistent(db_path: PathBuf) -> Self
Create a cache with persistent storage at the given path. Loads existing entries from disk if the file exists.
Sourcepub fn default_persistent() -> Self
pub fn default_persistent() -> Self
Create a cache using the default persistent path (~/.cache/sui/eval-cache.json).
Sourcepub fn with_graph_store(self, store: GraphStore) -> Self
pub fn with_graph_store(self, store: GraphStore) -> Self
Stack a GraphStore tier on this cache. Existing tiers
(in-memory + optional JSON file) are preserved verbatim. Calls
this builder-style: EvalCache::default_persistent().with_graph_store(gs).
Sourcepub fn with_all_tiers(db_path: PathBuf, store: GraphStore) -> Self
pub fn with_all_tiers(db_path: PathBuf, store: GraphStore) -> Self
Construct an EvalCache with all three tiers enabled.
- In-memory — always.
- JSON file — at
db_path(also loaded on construction). - GraphStore — using
store.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Whether the cache is enabled.
Sourcepub fn has_graph_store(&self) -> bool
pub fn has_graph_store(&self) -> bool
True iff the GraphStore tier is wired.
Sourcepub fn get(&mut self, key: &CacheKey) -> Option<&CachedValue>
pub fn get(&mut self, key: &CacheKey) -> Option<&CachedValue>
Look up a cached result. Tier order: memory → graph_store.
Behavior contract: a hit from the graph_store tier is
promoted into the memory tier so the next same-process lookup
is sub-microsecond. The promotion is the only mutation get
performs.
Sourcepub fn put(&mut self, key: CacheKey, value: CachedValue)
pub fn put(&mut self, key: CacheKey, value: CachedValue)
Store a result in the cache. Writes to memory unconditionally and to every wired persistence tier (JSON + GraphStore) best-effort. Tier writes never fail loudly — eval-cache puts are advisory; a failed write doesn’t change the correctness of the eval, just the chance of a future hit.
Sourcepub fn key_for_file(path: &Path) -> Option<CacheKey>
pub fn key_for_file(path: &Path) -> Option<CacheKey>
Compute the cache key for a file on disk.
The source hash is the SHA-256 of the file content. If a flake.lock
exists in the same directory, its hash is included as the lock_hash.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EvalCache
impl !UnwindSafe for EvalCache
impl Freeze for EvalCache
impl Send for EvalCache
impl Sync for EvalCache
impl Unpin for EvalCache
impl UnsafeUnpin for EvalCache
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
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> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.