pub struct Store { /* private fields */ }
Expand description
An MVCC-based transactional key-value store.
The store is closed asynchronously when it is dropped.
If you need to guarantee that the store is closed before the program continues, use the close
method.
Implementations§
source§impl Store
impl Store
sourcepub fn new(opts: Options) -> Result<Self>
pub fn new(opts: Options) -> Result<Self>
Creates a new MVCC key-value store with the given options.
sourcepub fn begin(&self) -> Result<Transaction>
pub fn begin(&self) -> Result<Transaction>
Begins a new read-write transaction. It creates a new transaction with the core and read-write mode, and sets the read timestamp from the oracle. It returns the transaction.
sourcepub fn begin_with_mode(&self, mode: Mode) -> Result<Transaction>
pub fn begin_with_mode(&self, mode: Mode) -> Result<Transaction>
Begins a new transaction with the given mode. It creates a new transaction with the core and the given mode, and sets the read timestamp from the oracle. It returns the transaction.
sourcepub fn view(&self, f: impl FnOnce(&mut Transaction) -> Result<()>) -> Result<()>
pub fn view(&self, f: impl FnOnce(&mut Transaction) -> Result<()>) -> Result<()>
Executes a function in a read-only transaction. It begins a new read-only transaction and executes the function with the transaction. It returns the result of the function.
sourcepub async fn write(
self: Arc<Self>,
f: impl FnOnce(&mut Transaction) -> Result<()>,
) -> Result<()>
pub async fn write( self: Arc<Self>, f: impl FnOnce(&mut Transaction) -> Result<()>, ) -> Result<()>
Executes a function in a read-write transaction and commits the transaction. It begins a new read-write transaction, executes the function with the transaction, and commits the transaction. It returns the result of the function.