From b279bc230bfd5df4695c7a095f687d5c3a184e97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristoffer=20Str=C3=B6m?= Date: Thu, 26 Dec 2019 17:21:09 +0100 Subject: [PATCH] Add flush functionality --- Cargo.toml | 2 +- src/lib.rs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 9025c4a..2b4578a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ authors = ["Kristoffer Ström ", "David Stainton "] 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"] diff --git a/src/lib.rs b/src/lib.rs index 8bb0dd7..db44f31 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -389,6 +389,17 @@ impl Index { } } + /// 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 {