pub struct CachePersistence { /* private fields */ }Expand description
Cache persistence handler
Manages saving and loading cache state to/from disk. Supports full snapshots and incremental updates.
Implementations§
Source§impl CachePersistence
impl CachePersistence
Sourcepub fn new(config: PersistenceConfig) -> Self
pub fn new(config: PersistenceConfig) -> Self
Create a new cache persistence handler
Sourcepub fn with_default_config() -> Self
pub fn with_default_config() -> Self
Create with default configuration
Sourcepub fn config(&self) -> &PersistenceConfig
pub fn config(&self) -> &PersistenceConfig
Get persistence configuration
Sourcepub fn stats(&self) -> PersistenceStats
pub fn stats(&self) -> PersistenceStats
Get persistence statistics
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Check if persistence is enabled
Sourcepub fn save_snapshot(
&self,
snapshot: &CacheSnapshot,
path: Option<&Path>,
) -> Result<usize>
pub fn save_snapshot( &self, snapshot: &CacheSnapshot, path: Option<&Path>, ) -> Result<usize>
Sourcepub fn load_snapshot(
&self,
path: Option<&Path>,
) -> Result<Option<CacheSnapshot>>
pub fn load_snapshot( &self, path: Option<&Path>, ) -> Result<Option<CacheSnapshot>>
Sourcepub fn should_save(&self, entries_count: usize) -> bool
pub fn should_save(&self, entries_count: usize) -> bool
Check if a save is needed based on configuration
Sourcepub fn delete_snapshot(&self, path: Option<&Path>) -> Result<bool>
pub fn delete_snapshot(&self, path: Option<&Path>) -> Result<bool>
Delete persisted cache snapshot
Sourcepub fn last_save_age(&self) -> Option<Duration>
pub fn last_save_age(&self) -> Option<Duration>
Get the age of the last save
Sourcepub fn reset_stats(&self)
pub fn reset_stats(&self)
Reset persistence statistics
Trait Implementations§
Source§impl Debug for CachePersistence
impl Debug for CachePersistence
Auto Trait Implementations§
impl Freeze for CachePersistence
impl !RefUnwindSafe for CachePersistence
impl Send for CachePersistence
impl Sync for CachePersistence
impl Unpin for CachePersistence
impl UnsafeUnpin for CachePersistence
impl !UnwindSafe for CachePersistence
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 moreSource§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.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.