Skip to main content

CacheAdapter

Trait CacheAdapter 

Source
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§

Source

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.

Source

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.

Source

fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>

Remove a cached value

Source

fn clear(&self) -> CacheOpFuture<'_>

Clear all cached values

Trait Implementations§

Source§

impl CacheAdapter for Box<dyn CacheAdapter>

Source§

fn get(&self, key: CacheKey) -> CacheGetFuture<'_>

Get a cached value by key Read more
Source§

fn set(&self, key: CacheKey, value: &[u8], ttl: Duration) -> CacheOpFuture<'_>

Set a cached value with a TTL Read more
Source§

fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>

Remove a cached value
Source§

fn clear(&self) -> CacheOpFuture<'_>

Clear all cached values

Implementations on Foreign Types§

Source§

impl CacheAdapter for Box<dyn CacheAdapter>

Source§

fn get(&self, key: CacheKey) -> CacheGetFuture<'_>

Source§

fn set(&self, key: CacheKey, value: &[u8], ttl: Duration) -> CacheOpFuture<'_>

Source§

fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>

Source§

fn clear(&self) -> CacheOpFuture<'_>

Source§

impl<T: CacheAdapter + ?Sized> CacheAdapter for Arc<T>

Source§

fn get(&self, key: CacheKey) -> CacheGetFuture<'_>

Source§

fn set(&self, key: CacheKey, value: &[u8], ttl: Duration) -> CacheOpFuture<'_>

Source§

fn remove(&self, key: CacheKey) -> CacheOpFuture<'_>

Source§

fn clear(&self) -> CacheOpFuture<'_>

Implementors§