pub trait KvStore:
Send
+ Sync
+ 'static {
// Required methods
fn get(
&self,
key: &[&str],
) -> impl Future<Output = Result<Option<Value>, KvError>> + Send;
fn set(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> impl Future<Output = Result<(), KvError>> + Send;
fn insert(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> impl Future<Output = Result<bool, KvError>> + Send;
fn delete(
&self,
key: &[&str],
) -> impl Future<Output = Result<(), KvError>> + Send;
}Expand description
A key-value store backend.
An entry past its expiry is absent, whether or not the backend has removed it yet.
Required Methods§
Sourcefn get(
&self,
key: &[&str],
) -> impl Future<Output = Result<Option<Value>, KvError>> + Send
fn get( &self, key: &[&str], ) -> impl Future<Output = Result<Option<Value>, KvError>> + Send
The value under key.
Sourcefn set(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> impl Future<Output = Result<(), KvError>> + Send
fn set( &self, key: &[&str], value: Value, ttl: Option<Duration>, ) -> impl Future<Output = Result<(), KvError>> + Send
Put value under key, replacing what was there, to expire after
ttl if given.
Sourcefn insert(
&self,
key: &[&str],
value: Value,
ttl: Option<Duration>,
) -> impl Future<Output = Result<bool, KvError>> + Send
fn insert( &self, key: &[&str], value: Value, ttl: Option<Duration>, ) -> impl Future<Output = Result<bool, KvError>> + Send
Put value under key only if nothing is there, and say whether it
was put. Of any number of callers at once, in any number of
processes, exactly one is told it was: this is what makes “has this
activity been processed?” safe to ask from two workers.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".