pub enum SyncPolicy {
Always,
Manual,
}std only.Expand description
When a write is made durable on disk.
bison-db never holds writes in a userspace buffer — every write reaches the
operating system immediately and is visible to later reads. This policy
controls only when the store forces those bytes through the OS cache to the
physical device with fsync, which is what protects them from a power loss.
§Examples
use bison_db::{DbOptions, SyncPolicy};
// Durable per write, at the cost of an fsync on every insert/update/delete.
let db = DbOptions::new().sync(SyncPolicy::Always).open(&path)?;Variants§
Always
fsync after every write before it returns. Each insert, update, and
delete is durable the moment the call completes, at the cost of one
device sync per operation.
Manual
fsync only when Db::flush is called (and once, best-effort, when the
store is dropped). Writes are still crash-safe — a torn write is never
misread — but the most recent unsynced writes can be lost on power loss.
This is the default, and the fastest policy.
Trait Implementations§
Source§impl Clone for SyncPolicy
impl Clone for SyncPolicy
Source§fn clone(&self) -> SyncPolicy
fn clone(&self) -> SyncPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for SyncPolicy
Source§impl Debug for SyncPolicy
impl Debug for SyncPolicy
Source§impl Default for SyncPolicy
impl Default for SyncPolicy
Source§fn default() -> SyncPolicy
fn default() -> SyncPolicy
impl Eq for SyncPolicy
Source§impl PartialEq for SyncPolicy
impl PartialEq for SyncPolicy
Source§fn eq(&self, other: &SyncPolicy) -> bool
fn eq(&self, other: &SyncPolicy) -> bool
self and other values to be equal, and is used by ==.