fjall-rs / fjall

🗻 LSM-based embeddable key-value storage engine written in safe Rust

Home Page:https://fjall-rs.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to flush manually

i18nsite opened this issue · comments

How to flush manually ?

the config not has method flush

will the config auto flush when drop?

From the README:

After writing data (be it, insert, remove or committing a write batch), you can choose to call Keyspace::persist which takes a FlushMode parameter. By default every 1000ms data is fsynced asynchronously. Also when dropped, the keyspace will try to persist the journal synchronously.

Example

use fjall::{Config, FlushMode};

pub fn main() -> fjall::Result<()> {
  let folder = std::path::Path::new("mydata");

  let keyspace = Config::new(folder).open()?;
  let items = keyspace.open_partition("items", Default::default())?;

  // Write some data
  items.insert("a", "hello")?;
  items.insert("b", "world")?;

  // Choose the FlushMode based on required durability guarantees
  keyspace.persist(FlushMode::SyncAll)?;

  Ok(())
}