diff --git a/src/rocksdb.rs b/src/rocksdb.rs index 93fcff7..62fd506 100644 --- a/src/rocksdb.rs +++ b/src/rocksdb.rs @@ -434,6 +434,12 @@ impl DB { self.write_opt(batch, &WriteOptions::default()) } + pub fn write_withou_wal(&self, batch: WriteBatch) -> Result<(), String> { + let mut wo = WriteOptions::new(); + wo.disable_wal(true); + self.write_opt(batch, &wo) + } + pub fn get_opt(&self, key: &[u8], readopts: &ReadOptions) diff --git a/src/rocksdb_options.rs b/src/rocksdb_options.rs index 6b16265..20f8a9c 100644 --- a/src/rocksdb_options.rs +++ b/src/rocksdb_options.rs @@ -334,11 +334,22 @@ impl WriteOptions { pub fn new() -> WriteOptions { WriteOptions::default() } + pub fn set_sync(&mut self, sync: bool) { unsafe { rocksdb_ffi::rocksdb_writeoptions_set_sync(self.inner, sync); } } + + pub fn disable_wal(&mut self, disable: bool) { + unsafe { + if disable { + rocksdb_ffi::rocksdb_writeoptions_disable_WAL(self.inner, 1); + } else { + rocksdb_ffi::rocksdb_writeoptions_disable_WAL(self.inner, 0); + } + } + } } impl Default for WriteOptions {