Skip to main content

FileCache

Trait FileCache 

Source
pub trait FileCache<V> {
    // Required methods
    fn get(&self, key: &str) -> Result<Option<V>>;
    fn get_stale(&self, key: &str) -> Result<Option<V>>;
    fn set(&self, key: &str, value: &V) -> Result<()>;
    fn remove(&self, key: &str) -> Result<()>;
}
Expand description

Trait for TTL-based filesystem caching.

Provides a unified interface for caching serializable data with time-to-live validation.

Required Methods§

Source

fn get(&self, key: &str) -> Result<Option<V>>

Get a cached value if it exists and is valid.

§Arguments
  • key - Cache key (filename without extension)
§Returns

The cached value if it exists and is within TTL, None otherwise.

Source

fn get_stale(&self, key: &str) -> Result<Option<V>>

Get a cached value regardless of TTL (stale fallback).

§Arguments
  • key - Cache key (filename without extension)
§Returns

The cached value if it exists, None otherwise.

Source

fn set(&self, key: &str, value: &V) -> Result<()>

Set a cached value.

§Arguments
  • key - Cache key (filename without extension)
  • value - Value to cache
Source

fn remove(&self, key: &str) -> Result<()>

Remove a cached value.

§Arguments
  • key - Cache key (filename without extension)

Implementors§

Source§

impl<V> FileCache<V> for FileCacheImpl<V>
where V: Serialize + for<'de> Deserialize<'de>,