Trait pliantdb_core::kv::Kv[][src]

pub trait Kv: Sized + Send + Sync {
    fn execute_key_operation<'life0, 'async_trait>(
        &'life0 self,
        op: KeyOperation
    ) -> Pin<Box<dyn Future<Output = Result<Output, Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn set_key<'a, S: Into<String>, V: Serialize + Send + Sync>(
        &'a self,
        key: S,
        value: &'a V
    ) -> Builder<'a, Self, V>

Notable traits for Builder<'a, K, V>

impl<'a, K, V> Future for Builder<'a, K, V> where
    K: Kv,
    V: Serialize + Send + Sync
type Output = Result<KeyStatus, Error>;
{ ... }
fn set_numeric_key<S: Into<String>, V: Into<Numeric>>(
        &self,
        key: S,
        value: V
    ) -> Builder<'_, Self, ()>

Notable traits for Builder<'a, K, V>

impl<'a, K, V> Future for Builder<'a, K, V> where
    K: Kv,
    V: Serialize + Send + Sync
type Output = Result<KeyStatus, Error>;
{ ... }
fn increment_key_by<S: Into<String> + Send + Sync, V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync>(
        &self,
        key: S,
        value: V
    ) -> Builder<'_, Self, V>

Notable traits for Builder<'a, K, V>

impl<'a, K, V> Future for Builder<'a, K, V> where
    K: Kv,
    V: TryFrom<Numeric, Error = IncompatibleTypeError>, 
type Output = Result<V, Error>;
{ ... }
fn decrement_key_by<S: Into<String> + Send + Sync, V: Into<Numeric> + TryFrom<Numeric, Error = IncompatibleTypeError> + Send + Sync>(
        &self,
        key: S,
        value: V
    ) -> Builder<'_, Self, V>

Notable traits for Builder<'a, K, V>

impl<'a, K, V> Future for Builder<'a, K, V> where
    K: Kv,
    V: TryFrom<Numeric, Error = IncompatibleTypeError>, 
type Output = Result<V, Error>;
{ ... }
fn get_key<S: Into<String>>(&self, key: S) -> Builder<'_, Self>

Notable traits for Builder<'a, K>

impl<'a, K> Future for Builder<'a, K> where
    K: Kv
type Output = Result<Option<Value>, Error>;
{ ... }
fn delete_key<'life0, 'async_trait, S: Into<String> + Send>(
        &'life0 self,
        key: S
    ) -> Pin<Box<dyn Future<Output = Result<KeyStatus, Error>> + Send + 'async_trait>>
    where
        S: 'async_trait,
        'life0: 'async_trait,
        Self: 'async_trait
, { ... }
fn key_namespace(&self) -> Option<&str> { ... }
fn with_key_namespace(&self, namespace: &str) -> Namespaced<'_, Self> { ... } }
Expand description

Key-Value store methods. The Key-Value store is designed to be a high-performance, lightweight storage mechanism.

When compared to Collections, the Key-Value store does not offer ACID-compliant transactions. Instead, the Key-Value store is made more efficient by periodically flushing the store to disk rather than during each operation. As such, the Key-Value store is intended to be used as a lightweight caching layer. However, because each of the operations it supports are executed atomically, the Key-Value store can also be utilized for synchronized locking.

Required methods

Executes a single KeyOperation.

Provided methods

Sets key to value. This function returns a builder that is also a Future. Awaiting the builder will execute Command::Set with the options given.

Sets key to value. This stores the value as a Numeric, enabling atomic math operations to be performed on this key. This function returns a builder that is also a Future. Awaiting the builder will execute Command::Set with the options given.

Increments key by value. The value stored must be a Numeric, otherwise an error will be returned. The result of the increment will be the value’s type. For example, if the stored value is currently a u64, but value is a f64, the current value will be converted to an f64, and the stored value will be an f64.

Decrements key by value. The value stored must be a Numeric, otherwise an error will be returned. The result of the decrement will be the value’s type. For example, if the stored value is currently a u64, but value is a f64, the current value will be converted to an f64, and the stored value will be an f64.

Gets the value stored at key. This function returns a builder that is also a Future. Awaiting the builder will execute Command::Get with the options given.

Deletes the value stored at key.

The current namespace.

Access this Key-Value store within a namespace. When using the returned Namespaced instance, all keys specified will be separated into their own storage designated by namespace.

Implementors