pub trait CacheStore: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ExtensionsError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set<'life0, 'async_trait>(
&'life0 self,
key: String,
value: Vec<u8>,
) -> Pin<Box<dyn Future<Output = Result<(), ExtensionsError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<bool, ExtensionsError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn set_with_ttl<'life0, 'async_trait>(
&'life0 self,
key: String,
value: Vec<u8>,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), ExtensionsError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn entry_count(&self) -> Option<u64> { ... }
}Expand description
Swappable key/value cache backend.
Required Methods§
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ExtensionsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, ExtensionsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Fetch the value for key, if present.
Provided Methods§
Sourcefn set_with_ttl<'life0, 'async_trait>(
&'life0 self,
key: String,
value: Vec<u8>,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), ExtensionsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_with_ttl<'life0, 'async_trait>(
&'life0 self,
key: String,
value: Vec<u8>,
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), ExtensionsError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Store value under key with a per-entry lifetime hint
(DW-037). Backends that cannot honor a per-entry TTL implement
the default (store without the hint); every reader re-checks
expiry from the value itself, so correctness never depends on
this. Defaulted, not abstract: existing implementations stay
valid backends without a change (extend, do not break).
Sourcefn entry_count(&self) -> Option<u64>
fn entry_count(&self) -> Option<u64>
Approximate number of live entries, when the backend can report it cheaply (DW-037 metrics gauge; None = not reportable). An estimate is acceptable — the consumer renders it as a gauge.