pub struct StrataKV { /* private fields */ }Expand description
Pure-Rust Bitcask key-value store with append-only WAL.
Implementations§
Source§impl StrataKV
impl StrataKV
Sourcepub fn open(wal_path: impl AsRef<Path>) -> Result<Self>
pub fn open(wal_path: impl AsRef<Path>) -> Result<Self>
Opens or creates a StrataKV database at the specified WAL file path.
Sourcepub fn put(&mut self, key: &str, val: &[u8]) -> Result<()>
pub fn put(&mut self, key: &str, val: &[u8]) -> Result<()>
Stores a key-value pair, appending to the WAL and updating the in-memory index.
Sourcepub fn delete(&mut self, key: &str) -> Result<bool>
pub fn delete(&mut self, key: &str) -> Result<bool>
Deletes a key by appending a tombstone record.
Sourcepub fn total_bytes(&self) -> Result<u64>
pub fn total_bytes(&self) -> Result<u64>
Returns total file size on disk in bytes.
Sourcepub fn live_data_bytes(&self) -> u64
pub fn live_data_bytes(&self) -> u64
Returns the sum of bytes utilized by all live keys, values, and frame headers.
Sourcepub fn dead_bytes_ratio(&self) -> Result<f64>
pub fn dead_bytes_ratio(&self) -> Result<f64>
Ratio of dead/reclaimable bytes in the WAL (0.0 to 1.0).
Sourcepub fn maybe_compact(&mut self, threshold: f64) -> Result<bool>
pub fn maybe_compact(&mut self, threshold: f64) -> Result<bool>
Compacts the log if the dead bytes ratio exceeds the specified threshold.
Sourcepub fn compact(&mut self) -> Result<()>
pub fn compact(&mut self) -> Result<()>
Compacts the log by writing all current active entries into a fresh compacted file.
Trait Implementations§
Auto Trait Implementations§
impl Forget for StrataKV
impl Freeze for StrataKV
impl Move for StrataKV
impl RefUnwindSafe for StrataKV
impl Send for StrataKV
impl Sync for StrataKV
impl Unpin for StrataKV
impl UnsafeUnpin for StrataKV
impl UnwindSafe for StrataKV
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more