pub trait CacheStore: Send + Sync {
// Required methods
fn get_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [CacheKey],
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn get_json<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>
where T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn set_json<'life0, 'life1, 'life2, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
value: &'life2 T,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>
where T: Serialize + Sync + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Expand description
Async cache store abstraction.
Required Methods§
Sourcefn get_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<Vec<u8>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads a raw value by key.
Sourcefn set_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set_raw<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 CacheKey,
value: Vec<u8>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Writes a raw value with optional TTL.
Provided Methods§
Sourcefn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [CacheKey],
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_many<'life0, 'life1, 'async_trait>(
&'life0 self,
keys: &'life1 [CacheKey],
) -> Pin<Box<dyn Future<Output = CacheResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes multiple values by key.
Backends can override this to batch keys by connection or shard. The default implementation preserves existing single-key semantics.
Sourcefn get_json<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_json<'life0, 'life1, 'async_trait, T>(
&'life0 self,
key: &'life1 CacheKey,
) -> Pin<Box<dyn Future<Output = CacheResult<Option<T>>> + Send + 'async_trait>>where
T: DeserializeOwned + Send + 'async_trait,
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Reads a JSON value by key.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.