4 releases (breaking)

0.4.0 May 13, 2023
0.3.0 Mar 8, 2023
0.2.0 Dec 20, 2022
0.1.0 Sep 26, 2022

#4 in #persisting

MIT license

39KB
637 lines

A persister targetting Sled.

Single persister

let db = sled::Config::new().temporary(true).open()?;
let changes_tree = db.open_tree("changes")?;
let documents_tree = db.open_tree("documents")?;
let sync_states_tree = db.open_tree("sync-states")?;

let persister = SledPersister::new(changes_tree, documents_tree, sync_states_tree, "")?;
let doc = PersistentAutomerge::load(persister);

Multiple persisters sharing the same trees

let db = sled::Config::new().temporary(true).open()?;
let changes_tree = db.open_tree("changes")?;
let documents_tree = db.open_tree("documents")?;
let sync_states_tree = db.open_tree("sync-states")?;

let persister1 = SledPersister::new(
    changes_tree.clone(),
    documents_tree.clone(),
    sync_states_tree.clone(),
    "1",
)?;
let doc1 = PersistentAutomerge::load(persister1);

let persister2 = SledPersister::new(changes_tree, documents_tree, sync_states_tree, "2")?;
let doc2 = PersistentAutomerge::load(persister2);

Dependencies

~6MB
~122K SLoC