Trait oasis_core_runtime::storage::mkvs::MKVS
source · pub trait MKVS {
// Required methods
fn get(&self, key: &[u8]) -> Option<Vec<u8>>;
fn get_proof(&self, key: &[u8]) -> Option<Proof>;
fn cache_contains_key(&self, key: &[u8]) -> bool;
fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>;
fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>;
fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16);
fn iter(&self) -> Box<dyn Iterator + '_>;
fn commit(
&mut self,
namespace: Namespace,
version: u64,
) -> Result<(WriteLog, Hash)>;
}
Expand description
Merklized key-value store.
Required Methods§
sourcefn cache_contains_key(&self, key: &[u8]) -> bool
fn cache_contains_key(&self, key: &[u8]) -> bool
Check if the local MKVS cache contains the given key.
While get can be used to check if the MKVS as a whole contains a given key, this function specifically guarantees that no remote syncing will be invoked, only checking the local cache.
sourcefn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>
fn insert(&mut self, key: &[u8], value: &[u8]) -> Option<Vec<u8>>
Update entry with given key.
If the database did not have this key present, None
is returned.
If the database did have this key present, the value is updated, and the old value is returned.
sourcefn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>
fn remove(&mut self, key: &[u8]) -> Option<Vec<u8>>
Remove entry with given key, returning the value at the key if the key was previously in the database.
sourcefn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16)
fn prefetch_prefixes(&self, prefixes: &[Prefix], limit: u16)
Populate the in-memory tree with nodes for keys starting with given prefixes.