pub struct DiskCache { /* private fields */ }Implementations§
Source§impl DiskCache
impl DiskCache
Sourcepub fn drain_write_failures(&self) -> u64
pub fn drain_write_failures(&self) -> u64
Returns the number of write failures accumulated since the last call and resets the
per-drain counter. The cumulative total_write_failures is never reset.
Sourcepub fn is_degraded(&self) -> bool
pub fn is_degraded(&self) -> bool
Returns true when cumulative write failures have reached DISK_CACHE_DEGRADED_THRESHOLD.
Callers can use this to emit a degraded health signal without polling the counter.
Source§impl DiskCache
impl DiskCache
Sourcepub fn new(base: PathBuf, disabled: bool) -> Self
pub fn new(base: PathBuf, disabled: bool) -> Self
Creates the cache directory (mode 0700) and returns a new instance.
If disabled is true, or if directory creation fails, all operations are no-ops.
pub fn entry_path(&self, tool: &str, key: &Hash) -> PathBuf
Sourcepub fn get<T: DeserializeOwned>(&self, tool: &str, key: &Hash) -> Option<T>
pub fn get<T: DeserializeOwned>(&self, tool: &str, key: &Hash) -> Option<T>
Returns None if entry is absent or corrupt. Never propagates errors.
Sourcepub fn put<T: Serialize>(&self, tool: &str, key: &Hash, value: &T)
pub fn put<T: Serialize>(&self, tool: &str, key: &Hash, value: &T)
Atomic write via NamedTempFile::persist (rename(2)). Silently drops all errors.
Sourcepub fn evict_stale(&self, retention_days: u64)
pub fn evict_stale(&self, retention_days: u64)
Removes files not accessed within retention_days. Best-effort; silently drops errors.
Auto Trait Implementations§
impl !Freeze for DiskCache
impl RefUnwindSafe for DiskCache
impl Send for DiskCache
impl Sync for DiskCache
impl Unpin for DiskCache
impl UnsafeUnpin for DiskCache
impl UnwindSafe for DiskCache
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> 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> 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