pub trait CacheBackend<T>: Send + Sync{
// Required methods
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
value: &'life3 T,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn invalidate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn invalidate_all<'life0, 'life1, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn invalidation_stream(
&self,
_keyspace: BackendKeyspace,
) -> BackendInvalidationStream<T::Id> { ... }
}Expand description
L2 cache backend for a single Cacheable payload type.
Backends receive a BackendKeyspace on every operation. They
should not carry an independent namespace because it could diverge
from the owning crate::punnu::Punnu.
Required Methods§
Sourcefn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<Option<T>, BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Read an entry from the backend.
Sourcefn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
value: &'life3 T,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn put<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
value: &'life3 T,
ttl: Option<Duration>,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Store an entry in the backend.
Sourcefn invalidate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn invalidate<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
id: &'life2 T::Id,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invalidate one backend entry and publish an id-scoped invalidation if supported.
Sourcefn invalidate_all<'life0, 'life1, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn invalidate_all<'life0, 'life1, 'async_trait>(
&'life0 self,
keyspace: &'life1 BackendKeyspace,
) -> Pin<Box<dyn Future<Output = Result<(), BackendError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Invalidate backend entries in this keyspace and publish an all-scoped invalidation if supported.
Backend implementations may need to scan or batch-delete native storage. Unless an implementation documents stronger guarantees, this is not a quiescence barrier against concurrent writers in the same keyspace.
Provided Methods§
Sourcefn invalidation_stream(
&self,
_keyspace: BackendKeyspace,
) -> BackendInvalidationStream<T::Id>
fn invalidation_stream( &self, _keyspace: BackendKeyspace, ) -> BackendInvalidationStream<T::Id>
Subscribe to backend invalidations for one keyspace.