pub struct OptimisticTxDatabase { /* private fields */ }Expand description
Transactional database
Implementations§
Source§impl OptimisticTxDatabase
impl OptimisticTxDatabase
Sourcepub fn builder(path: impl AsRef<Path>) -> DatabaseBuilder<Self>
pub fn builder(path: impl AsRef<Path>) -> DatabaseBuilder<Self>
Creates a new database builder to create or open a database at path.
Sourcepub fn write_tx(&self) -> Result<WriteTransaction>
pub fn write_tx(&self) -> Result<WriteTransaction>
Sourcepub fn persist(&self, mode: PersistMode) -> Result<()>
pub fn persist(&self, mode: PersistMode) -> Result<()>
Flushes the active journal. The durability depends on the PersistMode
used.
Persisting only affects durability, NOT consistency! Even without flushing data is crash-safe.
§Examples
let db = OptimisticTxDatabase::builder(folder).open()?;
let items = db.keyspace("my_items", KeyspaceCreateOptions::default)?;
items.insert("a", "hello")?;
db.persist(PersistMode::SyncAll)?;§Errors
Returns error, if an IO error occurred.
Sourcepub fn keyspace(
&self,
name: &str,
create_options: impl FnOnce() -> KeyspaceCreateOptions,
) -> Result<OptimisticTxKeyspace>
pub fn keyspace( &self, name: &str, create_options: impl FnOnce() -> KeyspaceCreateOptions, ) -> Result<OptimisticTxKeyspace>
Creates or opens a keyspace.
If the keyspace does not yet exist, it will be created configured with create_options.
Otherwise simply a handle to the existing keyspace will be returned.
Keyspace names can be up to 255 characters long and can not be empty.
§Errors
Returns error, if an IO error occurred.
§Panics
Panics if the keyspace name is invalid.
Sourcepub fn keyspace_count(&self) -> usize
pub fn keyspace_count(&self) -> usize
Returns the number of keyspaces.
Sourcepub fn list_keyspace_names(&self) -> Vec<StrView>
pub fn list_keyspace_names(&self) -> Vec<StrView>
Gets a list of all keyspace names in the database.
Sourcepub fn keyspace_exists(&self, name: &str) -> bool
pub fn keyspace_exists(&self, name: &str) -> bool
Returns true if the keyspace with the given name exists.
Sourcepub fn write_buffer_size(&self) -> u64
pub fn write_buffer_size(&self) -> u64
Returns the current write buffer size (active + sealed memtables).
Sourcepub fn journal_count(&self) -> usize
pub fn journal_count(&self) -> usize
Returns the number of journal fragments on disk.
Sourcepub fn disk_space(&self) -> Result<u64>
pub fn disk_space(&self) -> Result<u64>
Returns the disk space usage of the entire database.
§Errors
Returns error, if an IO error occurred.
Trait Implementations§
Source§impl Clone for OptimisticTxDatabase
impl Clone for OptimisticTxDatabase
Source§fn clone(&self) -> OptimisticTxDatabase
fn clone(&self) -> OptimisticTxDatabase
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more