pub trait CacheStore:
Any
+ Send
+ Sync
+ 'static {
// Required methods
fn store_name(&self) -> &str;
fn driver_name(&self) -> &str;
fn as_any(&self) -> &dyn Any;
fn supports_ttl(&self) -> bool;
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Cow<'life2, [u8]>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn forget<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn tagged(&self) -> Option<&dyn TaggedCacheStore> { ... }
}Expand description
Raw storage contract implemented by cache backends.
Stores know how to persist bytes. Selection, value encoding, configuration, and default-store behavior live above this boundary.
Required Methods§
fn store_name(&self) -> &str
fn driver_name(&self) -> &str
fn as_any(&self) -> &dyn Any
fn supports_ttl(&self) -> bool
Sourcefn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Bytes>>> + 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<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Return an immutable owning buffer, valid independently of this store. Memory backends share the allocation; eviction must not invalidate it.
Sourcefn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Cow<'life2, [u8]>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn put<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: Cow<'life2, [u8]>,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Store value under key. An owned buffer lets a backend that retains
bytes in process keep the allocation; others borrow it.
fn forget<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_entry<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<CacheEntry>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Read a value and its expiry together for a cache that can retain it. Backends without this information can still serve the current miss.
fn clear<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Sourcefn tagged(&self) -> Option<&dyn TaggedCacheStore>
fn tagged(&self) -> Option<&dyn TaggedCacheStore>
This store’s tagged operations, or None when it cannot keep tags.
The answer belongs to the built store, not to its driver: one driver
can build stores that differ, as an Orbit store does with and without
a backing store. A store answers Some only when an invalidation
reaches every value it can return afterwards, including what a miss
reads from a lower tier. Untagged operations do not depend on it.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".