pub struct FileCache { /* private fields */ }Expand description
Generic file-based cache for storing serializable data
Implementations§
Source§impl FileCache
impl FileCache
Sourcepub fn new<P: AsRef<Path>>(cache_dir: P) -> Result<Self>
pub fn new<P: AsRef<Path>>(cache_dir: P) -> Result<Self>
Create a new FileCache with the given cache directory
Sourcepub fn with_default_ttl(self, ttl_seconds: u64) -> Self
pub fn with_default_ttl(self, ttl_seconds: u64) -> Self
Set a default TTL for cached entries (in seconds)
Sourcepub fn get<T>(&self, key: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
pub fn get<T>(&self, key: &str) -> Result<Option<T>>where
T: for<'de> Deserialize<'de>,
Get cached data by key
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