From 649bbf007e2b4363014f4f563c0151d5a16d0471 Mon Sep 17 00:00:00 2001 From: extrawurst Date: Thu, 4 Apr 2024 15:18:24 +0200 Subject: [PATCH] matching redb behaviour and flush after any write --- src/sled_store.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sled_store.rs b/src/sled_store.rs index fa6af45..a38e36a 100644 --- a/src/sled_store.rs +++ b/src/sled_store.rs @@ -50,6 +50,7 @@ impl StoreImpl for SledStore { let mut serializer = rmp_serde::Serializer::new(Vec::new()).with_struct_map(); value.serialize(&mut serializer)?; self.db.insert(key, serializer.into_inner())?; + self.db.flush()?; Ok(()) } @@ -57,6 +58,7 @@ impl StoreImpl for SledStore { fn set_string(&mut self, key: &str, value: &str) -> Result<(), Self::SetError> { let bytes = rmp_serde::to_vec(value)?; self.db.insert(key, bytes)?; + self.db.flush()?; Ok(()) } @@ -72,6 +74,7 @@ impl StoreImpl for SledStore { /// clear is also a kind of store so it will return SetError on failure fn clear(&mut self) -> Result<(), Self::SetError> { self.db.clear()?; + self.db.flush()?; Ok(()) } }