Skip to main content

KvStore

Trait KvStore 

Source
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§

Source

fn get( &self, key: &[&str], ) -> impl Future<Output = Result<Option<Value>, KvError>> + Send

The value under key.

Source

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.

Source

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.

Source

fn delete( &self, key: &[&str], ) -> impl Future<Output = Result<(), KvError>> + Send

Remove what is under key, if anything is.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§