pub trait Cache: Send + Sync {
// Required methods
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 [u8],
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn increment<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn multi_get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<u8>>>, Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
}Required Methods§
fn get<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Vec<u8>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn set<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
key: &'life1 str,
value: &'life2 [u8],
ttl: Duration,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'async_trait>(
&'life0 self,
key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
Sourcefn increment<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn increment<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
_delta: i64,
) -> Pin<Box<dyn Future<Output = Result<i64, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Atomically increment the value at key by delta, returning the new value.
Backends that cannot increment return an error.
Sourcefn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn ttl<'life0, 'life1, 'async_trait>(
&'life0 self,
_key: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<Duration>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the remaining time-to-live of key, or None if the key does not exist.
Sourcefn multi_get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<u8>>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn multi_get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_keys: &'life1 [&'life2 str],
) -> Pin<Box<dyn Future<Output = Result<Vec<Option<Vec<u8>>>, Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch multiple keys in one round trip. Missing keys yield None.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".