mirror of
https://gitlab.com/famedly/conduit.git
synced 2025-07-02 16:38:36 +00:00
KvTree: asyncify clear and increment
This commit is contained in:
parent
a8c9e3eebe
commit
7658414fc4
62 changed files with 958 additions and 650 deletions
|
@ -42,6 +42,7 @@ pub trait KeyValueDatabaseEngine: Send + Sync {
|
|||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
pub trait KvTree: Send + Sync {
|
||||
fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>>;
|
||||
|
||||
|
@ -58,7 +59,7 @@ pub trait KvTree: Send + Sync {
|
|||
backwards: bool,
|
||||
) -> Box<dyn Send + Iterator<Item = (Vec<u8>, Vec<u8>)> + 'a>;
|
||||
|
||||
fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
|
||||
async fn increment(&self, key: &[u8]) -> Result<Vec<u8>>;
|
||||
fn increment_batch(&self, iter: &mut dyn Iterator<Item = Vec<u8>>) -> Result<()>;
|
||||
|
||||
fn scan_prefix<'a>(
|
||||
|
@ -68,7 +69,7 @@ pub trait KvTree: Send + Sync {
|
|||
|
||||
fn watch_prefix<'a>(&'a self, prefix: &[u8]) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
|
||||
|
||||
fn clear(&self) -> Result<()> {
|
||||
async fn clear(&self) -> Result<()> {
|
||||
for (key, _) in self.iter() {
|
||||
self.remove(&key)?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue