Skip to main content

KvStore

Trait KvStore 

Source
pub trait KvStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Option<Bytes>>;
    fn set<'a>(
        &'a self,
        key: &'a str,
        val: Bytes,
        ttl: Option<Duration>,
    ) -> BoxFuture<'a, ()>;
    fn remove<'a>(&'a self, key: &'a str) -> BoxFuture<'a, ()>;
    fn incr<'a>(
        &'a self,
        key: &'a str,
        by: i64,
        ttl: Option<Duration>,
    ) -> BoxFuture<'a, u64>;
    fn clear_prefix<'a>(&'a self, prefix: &'a str) -> BoxFuture<'a, u64>;
}

Required Methods§

Source

fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Option<Bytes>>

Source

fn set<'a>( &'a self, key: &'a str, val: Bytes, ttl: Option<Duration>, ) -> BoxFuture<'a, ()>

Source

fn remove<'a>(&'a self, key: &'a str) -> BoxFuture<'a, ()>

Source

fn incr<'a>( &'a self, key: &'a str, by: i64, ttl: Option<Duration>, ) -> BoxFuture<'a, u64>

Atomic increment; creates the key at by when missing. Returns new value.

Source

fn clear_prefix<'a>(&'a self, prefix: &'a str) -> BoxFuture<'a, u64>

Remove keys starting with prefix. Returns how many were removed.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§