pub struct CacheManager { /* private fields */ }Expand description
File-based cache manager
Stores cache entries as JSON files in a cache directory. Supports TTL and manual invalidation strategies.
Implementations§
Source§impl CacheManager
impl CacheManager
Sourcepub fn new(cache_dir: impl AsRef<Path>) -> StorageResult<Self>
pub fn new(cache_dir: impl AsRef<Path>) -> StorageResult<Self>
Sourcepub fn set(
&self,
key: &str,
data: String,
strategy: CacheInvalidationStrategy,
) -> StorageResult<()>
pub fn set( &self, key: &str, data: String, strategy: CacheInvalidationStrategy, ) -> StorageResult<()>
Sourcepub fn invalidate(&self, key: &str) -> StorageResult<bool>
pub fn invalidate(&self, key: &str) -> StorageResult<bool>
Sourcepub fn exists(&self, key: &str) -> StorageResult<bool>
pub fn exists(&self, key: &str) -> StorageResult<bool>
Sourcepub fn clear(&self) -> StorageResult<()>
pub fn clear(&self) -> StorageResult<()>
Sourcepub fn cleanup_expired(&self) -> StorageResult<usize>
pub fn cleanup_expired(&self) -> StorageResult<usize>
Clean up expired entries
Scans the cache directory and removes all expired entries.
§Returns
Returns the number of entries cleaned up
Auto Trait Implementations§
impl Freeze for CacheManager
impl RefUnwindSafe for CacheManager
impl Send for CacheManager
impl Sync for CacheManager
impl Unpin for CacheManager
impl UnwindSafe for CacheManager
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