*: add an option to disable write-ahead-log.

master
ngaut 9 years ago committed by Karl Hobley
parent f781adc84b
commit 0dfdc06ddf
  1. 6
      src/rocksdb.rs
  2. 11
      src/rocksdb_options.rs

@ -434,6 +434,12 @@ impl DB {
self.write_opt(batch, &WriteOptions::default()) 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, pub fn get_opt(&self,
key: &[u8], key: &[u8],
readopts: &ReadOptions) readopts: &ReadOptions)

@ -334,11 +334,22 @@ impl WriteOptions {
pub fn new() -> WriteOptions { pub fn new() -> WriteOptions {
WriteOptions::default() WriteOptions::default()
} }
pub fn set_sync(&mut self, sync: bool) { pub fn set_sync(&mut self, sync: bool) {
unsafe { unsafe {
rocksdb_ffi::rocksdb_writeoptions_set_sync(self.inner, sync); 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 { impl Default for WriteOptions {

Loading…
Cancel
Save