Skip to main content

KeyValueStore

Trait KeyValueStore 

Source
pub trait KeyValueStore: Send + Sync {
    // Required methods
    fn get_all(&self) -> HashMap<String, Value>;
    fn get(&self, key: &str) -> Option<Value>;
    fn set(&self, key: &str, value: Value);
    fn mset(&self, kv_pairs: &[(String, Value)]);
    fn exists(&self, key: &str) -> bool;
    fn keys(&self) -> Vec<String>;
    fn mget(&self, keys: &[String]) -> HashMap<String, Value>;
    fn delete(&self, key: &str);
    fn get_prefix(&self, prefix: &str) -> HashMap<String, Value>;
}
Expand description

Abstract interface for key-value storage backends

Required Methods§

Source

fn get_all(&self) -> HashMap<String, Value>

Get all key-value pairs

Source

fn get(&self, key: &str) -> Option<Value>

Get value for key

Source

fn set(&self, key: &str, value: Value)

Set value for key

Source

fn mset(&self, kv_pairs: &[(String, Value)])

Source

fn exists(&self, key: &str) -> bool

Check if key exists

Source

fn keys(&self) -> Vec<String>

Get all keys matching pattern

Source

fn mget(&self, keys: &[String]) -> HashMap<String, Value>

Batch get multiple keys, returns map with found key-value pairs

Source

fn delete(&self, key: &str)

Delete a key

Source

fn get_prefix(&self, prefix: &str) -> HashMap<String, Value>

Get all key-value pairs with keys starting with the given prefix

Implementors§