pub struct FileCacheImpl<V> { /* private fields */ }Expand description
File-based cache implementation with TTL support.
Stores serialized data in JSON files with embedded metadata. When cache directory is unavailable (None), all operations become no-ops.
Implementations§
Source§impl<V> FileCacheImpl<V>where
V: Serialize + for<'de> Deserialize<'de>,
impl<V> FileCacheImpl<V>where
V: Serialize + for<'de> Deserialize<'de>,
Sourcepub fn new(subdirectory: impl Into<String>, ttl: Duration) -> Self
pub fn new(subdirectory: impl Into<String>, ttl: Duration) -> Self
Create a new file cache with default cache directory.
§Arguments
subdirectory- Subdirectory within cache directoryttl- Time-to-live for cache entries
If the cache directory cannot be determined, caching is disabled and a warning is emitted.
Sourcepub fn with_dir(
cache_dir: Option<PathBuf>,
subdirectory: impl Into<String>,
ttl: Duration,
) -> Self
pub fn with_dir( cache_dir: Option<PathBuf>, subdirectory: impl Into<String>, ttl: Duration, ) -> Self
Create a new file cache with custom cache directory.
§Arguments
cache_dir- Base cache directory (None to disable caching)subdirectory- Subdirectory within cache directoryttl- Time-to-live for cache entries
Trait Implementations§
Source§impl<V> FileCache<V> for FileCacheImpl<V>where
V: Serialize + for<'de> Deserialize<'de>,
impl<V> FileCache<V> for FileCacheImpl<V>where
V: Serialize + for<'de> Deserialize<'de>,
Auto Trait Implementations§
impl<V> Freeze for FileCacheImpl<V>
impl<V> RefUnwindSafe for FileCacheImpl<V>where
V: RefUnwindSafe,
impl<V> Send for FileCacheImpl<V>where
V: Send,
impl<V> Sync for FileCacheImpl<V>where
V: Sync,
impl<V> Unpin for FileCacheImpl<V>where
V: Unpin,
impl<V> UnwindSafe for FileCacheImpl<V>where
V: UnwindSafe,
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 more