implement flush() and cleanup() for rocksdb

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
strawberry 2024-03-06 18:02:19 -05:00 committed by June
parent 0df17a4103
commit 7cbb0139f2

View file

@ -4,7 +4,10 @@ use std::{
sync::{Arc, RwLock},
};
use rocksdb::LogLevel::{Debug, Error, Fatal, Info, Warn};
use rocksdb::{
FlushOptions,
LogLevel::{Debug, Error, Fatal, Info, Warn},
};
use tracing::{debug, info};
use super::{super::Config, watchers::Watchers, KeyValueDatabaseEngine, KvTree};
@ -143,7 +146,9 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
}
fn flush(&self) -> Result<()> {
// TODO?
debug!("Running flush_wal (no sync)");
rocksdb::DBCommon::flush_wal(&self.rocks, false)?;
Ok(())
}
@ -161,6 +166,13 @@ impl KeyValueDatabaseEngine for Arc<Engine> {
))
}
fn cleanup(&self) -> Result<()> {
debug!("Running flush_opt");
rocksdb::DBCommon::flush_opt(&self.rocks, &FlushOptions::default())?;
Ok(())
}
// TODO: figure out if this is needed for rocksdb
#[allow(dead_code)]
fn clear_caches(&self) {}