[][src]Trait agilulf::AsyncDatabase

pub trait AsyncDatabase: Send + Sync {
    fn get(
        &self,
        key: Slice
    ) -> Pin<Box<dyn Future<Output = Result<Slice>> + Send>>;
fn put(
        &self,
        key: Slice,
        value: Slice
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>;
fn scan(
        &self,
        start: Slice,
        end: Slice
    ) -> Pin<Box<dyn Future<Output = Vec<(Slice, Slice)>> + Send>>;
fn delete(
        &self,
        key: Slice
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>; }

Abstraction layer for a AsyncDatabase. Every method return a Future.

The return type of these function are fixed as Pin<Box<dyn Future<Output = Result<_>> + Send + '_>> rather than a generic type for convenience.

Required methods

fn get(&self, key: Slice) -> Pin<Box<dyn Future<Output = Result<Slice>> + Send>>

fn put(
    &self,
    key: Slice,
    value: Slice
) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>

fn scan(
    &self,
    start: Slice,
    end: Slice
) -> Pin<Box<dyn Future<Output = Vec<(Slice, Slice)>> + Send>>

SCAN don't return a Result because if nothing is found, an empty vector will be returned.

fn delete(&self, key: Slice) -> Pin<Box<dyn Future<Output = Result<()>> + Send>>

Loading content...

Implementors

impl AsyncDatabase for Database[src]

fn get(
    &self,
    key: Slice
) -> Pin<Box<dyn Future<Output = DatabaseResult<Slice>> + Send>>
[src]

GET request for the database will firstly read from MemDatabase. And then read from frozen database . Then will find in SSTable. If they are all not found, error will be returned.

fn put(
    &self,
    key: Slice,
    value: Slice
) -> Pin<Box<dyn Future<Output = DatabaseResult<()>> + Send>>
[src]

PUT request to this database will simply run PUT command on MemDatabase and check whether MemDatabase is so big that needs to freeze.

fn scan(
    &self,
    start: Slice,
    end: Slice
) -> Pin<Box<dyn Future<Output = Vec<(Slice, Slice)>> + Send>>
[src]

SCAN operation will merge every iterator from MemDatabase and FrozenDatabase and SStable together and return.

impl<T: SyncDatabase> AsyncDatabase for T[src]

Every sync database can be wrapped as an async database easily. With this wrapper, MemDatabase can be used directly on Server.

Loading content...