Skip to main content

CacheStore

Trait CacheStore 

Source
pub trait CacheStore: Send + Sync {
    // Required methods
    fn get(
        &self,
        key: &str,
    ) -> DataFuture<'_, Result<Option<String>, DataError>>;
    fn set(
        &self,
        key: &str,
        value: &str,
        ttl_seconds: Option<u64>,
    ) -> DataFuture<'_, Result<(), DataError>>;
    fn delete(&self, key: &str) -> DataFuture<'_, Result<(), DataError>>;
}
Expand description

CacheStore Trait

A trait for implementing cache storage backends. Provides key-value caching operations with optional TTL.

§Methods

  • get: Retrieves a value by key
  • set: Stores a value with optional expiration
  • delete: Removes a value by key

Required Methods§

Source

fn get(&self, key: &str) -> DataFuture<'_, Result<Option<String>, DataError>>

Retrieves a cached value by key.

Returns None if the key doesn’t exist or has expired.

Source

fn set( &self, key: &str, value: &str, ttl_seconds: Option<u64>, ) -> DataFuture<'_, Result<(), DataError>>

Stores a value in the cache.

§Arguments
  • key: The cache key
  • value: The value to store
  • ttl_seconds: Optional expiration time in seconds
Source

fn delete(&self, key: &str) -> DataFuture<'_, Result<(), DataError>>

Removes a value from the cache.

Implementors§