pub trait CacheAdapter: Send + Sync {
// Required methods
fn get(&self, key: CacheKey) -> CacheGetFuture<'_>;
fn set(
&self,
key: CacheKey,
value: &[u8],
ttl: Duration,
) -> CacheOpFuture<'_>;
fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>;
fn clear(&self) -> CacheOpFuture<'_>;
}Expand description
Trait for cache adapters
This trait defines the interface for caching operations. Implementations can provide different storage backends (filesystem, memory, etc.) while maintaining the same API.
Required Methods§
Sourcefn get(&self, key: CacheKey) -> CacheGetFuture<'_>
fn get(&self, key: CacheKey) -> CacheGetFuture<'_>
Get a cached value by key
Returns Ok(Some(data)) if the key exists and hasn’t expired,
Ok(None) if the key doesn’t exist or has expired,
or Err(...) on I/O or other errors.
Sourcefn set(&self, key: CacheKey, value: &[u8], ttl: Duration) -> CacheOpFuture<'_>
fn set(&self, key: CacheKey, value: &[u8], ttl: Duration) -> CacheOpFuture<'_>
Set a cached value with a TTL
The value will be considered expired after ttl has elapsed.
Sourcefn remove(&self, key: CacheKey) -> CacheOpFuture<'_>
fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>
Remove a cached value
Sourcefn clear(&self) -> CacheOpFuture<'_>
fn clear(&self) -> CacheOpFuture<'_>
Clear all cached values