pub struct Env { /* private fields */ }
Expand description
Environment, required to start any transactions. Thread-safe, but opening the same database several times in the same process is not cross-platform.
Implementations
sourceimpl Env
impl Env
sourcepub fn file_size<P: AsRef<Path>>(path: P) -> Result<u64, Error>
pub fn file_size<P: AsRef<Path>>(path: P) -> Result<u64, Error>
File size of the database path, if it exists.
sourcepub fn set_flush_limit(&mut self, flush: u64)
pub fn set_flush_limit(&mut self, flush: u64)
Set the maximum number of dirty pages before triggering a flush.
sourcepub fn flush_limit(&self) -> u64
pub fn flush_limit(&self) -> u64
Get the maximum number of dirty pages before triggering a flush.
sourcepub fn new<P: AsRef<Path>>(path: P, length: u64) -> Result<Env, Error>
pub fn new<P: AsRef<Path>>(path: P, length: u64) -> Result<Env, Error>
Initialize an environment. length
must be a strictly
positive multiple of 4096. The same file can only be open in
one process or thread at the same time, and this is enforced
by a locked file.
sourcepub unsafe fn new_nolock<P: AsRef<Path>>(
path: P,
length: u64
) -> Result<Env, Error>
pub unsafe fn new_nolock<P: AsRef<Path>>(
path: P,
length: u64
) -> Result<Env, Error>
Same as new
, but does not take a lock on the file
system.
This method is provided because waiting for a lock on the file system may block the whole process, whereas.
However, the database is very likely to get corrupted if open more than once at the same time, even within the same process.
Therefore, do not use this method without another locking mechanism in place to avoid that situation.