pub struct PersistenceManager { /* private fields */ }Expand description
Manager for automatic cache persistence
Handles periodic saves, shutdown persistence, and recovery.
Implementations§
Source§impl PersistenceManager
impl PersistenceManager
Sourcepub fn new(config: PersistenceConfig) -> Self
pub fn new(config: PersistenceConfig) -> Self
Create a new persistence manager
Sourcepub fn with_default_config() -> Self
pub fn with_default_config() -> Self
Create with default configuration
Sourcepub fn start_background_task(
&self,
snapshot_provider: Arc<dyn Fn() -> Option<CacheSnapshot> + Send + Sync>,
)
pub fn start_background_task( &self, snapshot_provider: Arc<dyn Fn() -> Option<CacheSnapshot> + Send + Sync>, )
Start background persistence task
This starts a task that periodically saves the cache based on the configured strategy and interval.
Sourcepub fn stop_background_task(&self)
pub fn stop_background_task(&self)
Stop the background persistence task
Sourcepub fn shutdown(&self, final_snapshot: Option<CacheSnapshot>)
pub fn shutdown(&self, final_snapshot: Option<CacheSnapshot>)
Perform graceful shutdown with final cache save
§Arguments
final_snapshot- The final cache snapshot to save
Sourcepub fn recover(&self) -> Result<Option<CacheSnapshot>>
pub fn recover(&self) -> Result<Option<CacheSnapshot>>
Recover cache from persisted snapshot
§Returns
The recovered cache snapshot, or None if no snapshot exists
Sourcepub fn has_recovery_snapshot(&self) -> bool
pub fn has_recovery_snapshot(&self) -> bool
Check if a recovery snapshot exists
Sourcepub fn config(&self) -> &PersistenceConfig
pub fn config(&self) -> &PersistenceConfig
Get the persistence configuration
Sourcepub fn stats(&self) -> PersistenceStats
pub fn stats(&self) -> PersistenceStats
Get persistence statistics
Sourcepub fn last_snapshot(&self) -> Option<CacheSnapshot>
pub fn last_snapshot(&self) -> Option<CacheSnapshot>
Get the last saved snapshot
Sourcepub fn force_save(&self, snapshot: &CacheSnapshot) -> Result<usize>
pub fn force_save(&self, snapshot: &CacheSnapshot) -> Result<usize>
Force an immediate save
Sourcepub fn delete_persisted(&self) -> Result<bool>
pub fn delete_persisted(&self) -> Result<bool>
Delete persisted snapshot
Trait Implementations§
Source§impl Default for PersistenceManager
impl Default for PersistenceManager
Auto Trait Implementations§
impl Freeze for PersistenceManager
impl !RefUnwindSafe for PersistenceManager
impl Send for PersistenceManager
impl Sync for PersistenceManager
impl Unpin for PersistenceManager
impl UnsafeUnpin for PersistenceManager
impl !UnwindSafe for PersistenceManager
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.