pub struct FileCache {
pub cfg: CacheConfig,
}Expand description
Simple day-rolling file cache that sits in front of data-source fetches.
Fields§
§cfg: CacheConfigActive configuration (public for inspection / overrides).
Implementations§
Source§impl FileCache
impl FileCache
Sourcepub fn new(cfg: CacheConfig) -> Self
pub fn new(cfg: CacheConfig) -> Self
Wraps a CacheConfig into a new cache instance.
Sourcepub async fn load_or_fetch(
&self,
prefix: &str,
extension: &str,
url: &str,
max_age: Duration,
client: &Client,
) -> Result<Vec<u8>>
pub async fn load_or_fetch( &self, prefix: &str, extension: &str, url: &str, max_age: Duration, client: &Client, ) -> Result<Vec<u8>>
Returns cached bytes if a fresh file exists, otherwise fetches url,
stores the result under the day-stamped filename, and returns the bytes.
Stale files (older than max_age) for the same prefix/extension
pair are automatically cleaned up after a successful fetch.
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 UnsafeUnpin 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