Skip to content

Commit

Permalink
Add flush functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
krl committed Dec 26, 2019
1 parent 43e242d commit b279bc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Kristoffer Ström <kristoffer@rymdkoloni.se>",
"David Stainton <dawuud@riseup.net>"]
edition = "2018"
name = "appendix"
version = "0.1.3"
version = "0.2.0"
description = "Append-only, on-disk key-value index"
documentation = "https://docs.rs/appendix/"
keywords = ["index", "datastructure"]
Expand Down
11 changes: 11 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,17 @@ impl<K: Hash + Copy + PartialEq, V: Hash + Copy> Index<K, V> {
}
}

/// Syncronizes and flushes data to disk
pub fn flush(&mut self) -> std::io::Result<()> {
unsafe {
let lanes = &mut *self.lanes.get();
for mmap in lanes {
mmap.flush()?;
}
}
Ok(())
}

/// Removes all data from disk
pub fn purge(&mut self) -> std::io::Result<()> {
for n in 0..NUM_LANES {
Expand Down

0 comments on commit b279bc2

Please sign in to comment.