pub struct FileCache { /* private fields */ }
Expand description
File-based cache implementation
Implementations§
Source§impl FileCache
impl FileCache
Sourcepub fn new(config: CacheConfig) -> Self
pub fn new(config: CacheConfig) -> Self
Create a new file cache with the given configuration
Sourcepub async fn store<T>(&self, key: &str, data: T) -> Result<()>where
T: Serialize,
pub async fn store<T>(&self, key: &str, data: T) -> Result<()>where
T: Serialize,
Store data in the cache
Sourcepub async fn get<T>(&self, key: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
pub async fn get<T>(&self, key: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
Retrieve data from the cache
Sourcepub async fn exists(&self, key: &str) -> Result<bool>
pub async fn exists(&self, key: &str) -> Result<bool>
Check if a key exists in the cache and is not expired
Sourcepub async fn stats(&self) -> Result<CacheStats>
pub async fn stats(&self) -> Result<CacheStats>
Get cache statistics
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileCache
impl RefUnwindSafe for FileCache
impl Send for FileCache
impl Sync for FileCache
impl Unpin for FileCache
impl UnwindSafe for FileCache
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