pub struct Transaction { /* private fields */ }
Expand description
Transaction
is a struct representing a transaction in a database.
Implementations§
Source§impl Transaction
impl Transaction
Sourcepub fn new(core: Arc<Core>, mode: Mode) -> Result<Self>
pub fn new(core: Arc<Core>, mode: Mode) -> Result<Self>
Prepare a new transaction in the given mode.
Sourcepub fn set_durability(&mut self, durability: Durability)
pub fn set_durability(&mut self, durability: Durability)
Sets the durability level of the transaction.
Sourcepub fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()>
pub fn set(&mut self, key: &[u8], value: &[u8]) -> Result<()>
Adds a key-value pair to the store.
Sourcepub fn insert_or_replace(&mut self, key: &[u8], value: &[u8]) -> Result<()>
pub fn insert_or_replace(&mut self, key: &[u8], value: &[u8]) -> Result<()>
Inserts if not present or replaces an existing key-value pair.
Sourcepub fn set_at_ts(&mut self, key: &[u8], value: &[u8], ts: u64) -> Result<()>
pub fn set_at_ts(&mut self, key: &[u8], value: &[u8], ts: u64) -> Result<()>
Adds a key-value pair to the store with the given timestamp.
Sourcepub fn delete(&mut self, key: &[u8]) -> Result<()>
pub fn delete(&mut self, key: &[u8]) -> Result<()>
Delete all the versions of a key. This is a hard delete. This will remove the key from the index and disk.
Sourcepub fn soft_delete(&mut self, key: &[u8]) -> Result<()>
pub fn soft_delete(&mut self, key: &[u8]) -> Result<()>
Mark all versions of a key as deleted. This is a soft delete, and does not remove the key from the index, or disk, rather just marks it as deleted, and the key will remain hidden.
Sourcepub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
pub fn get(&mut self, key: &[u8]) -> Result<Option<Vec<u8>>>
Gets a value for a key if it exists.
Sourcepub fn scan<'b, R>(
&'b mut self,
range: R,
limit: Option<usize>,
) -> Result<Vec<(Vec<u8>, Vec<u8>, u64, u64)>>where
R: RangeBounds<&'b [u8]>,
pub fn scan<'b, R>(
&'b mut self,
range: R,
limit: Option<usize>,
) -> Result<Vec<(Vec<u8>, Vec<u8>, u64, u64)>>where
R: RangeBounds<&'b [u8]>,
Scans a range of keys and returns a vector of tuples containing the value, version, and timestamp for each key.
Sourcepub async fn commit(&mut self) -> Result<()>
pub async fn commit(&mut self) -> Result<()>
Commits the transaction, by writing all pending entries to the store.
Sourcepub fn set_savepoint(&mut self) -> Result<()>
pub fn set_savepoint(&mut self) -> Result<()>
After calling this method the subsequent modifications within this
transaction can be rolled back by calling rollback_to_savepoint
.
This method is stackable and can be called multiple times with the
corresponding calls to rollback_to_savepoint
.
Sourcepub fn rollback_to_savepoint(&mut self) -> Result<()>
pub fn rollback_to_savepoint(&mut self) -> Result<()>
Rollback the state of the transaction to the latest savepoint set by
calling set_savepoint
.
Source§impl Transaction
impl Transaction
Implement Versioned APIs for read-only transactions. These APIs do not take part in conflict detection.
Sourcepub fn get_at_ts(&self, key: &[u8], ts: u64) -> Result<Option<Vec<u8>>>
pub fn get_at_ts(&self, key: &[u8], ts: u64) -> Result<Option<Vec<u8>>>
Returns the value associated with the key at the given timestamp.
Sourcepub fn get_history(&self, key: &[u8]) -> Result<Vec<(Vec<u8>, u64)>>
pub fn get_history(&self, key: &[u8]) -> Result<Vec<(Vec<u8>, u64)>>
Returns all the versioned values and timestamps associated with the key.
Sourcepub fn scan_at_ts<'b, R>(
&'b self,
range: R,
ts: u64,
limit: Option<usize>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>>where
R: RangeBounds<&'b [u8]>,
pub fn scan_at_ts<'b, R>(
&'b self,
range: R,
ts: u64,
limit: Option<usize>,
) -> Result<Vec<(Vec<u8>, Vec<u8>)>>where
R: RangeBounds<&'b [u8]>,
Returns key-value pairs within the specified range, at the given timestamp.
Sourcepub fn keys_at_ts<'b, R>(&'b self, range: R, ts: u64) -> Result<Vec<Vec<u8>>>where
R: RangeBounds<&'b [u8]>,
pub fn keys_at_ts<'b, R>(&'b self, range: R, ts: u64) -> Result<Vec<Vec<u8>>>where
R: RangeBounds<&'b [u8]>,
Returns keys within the specified range, at the given timestamp.
Sourcepub fn get_value_by_query(
&self,
key: &VariableSizeKey,
query_type: QueryType,
) -> Result<Option<(Vec<u8>, u64, u64)>>
pub fn get_value_by_query( &self, key: &VariableSizeKey, query_type: QueryType, ) -> Result<Option<(Vec<u8>, u64, u64)>>
Returns the value associated with the key at the given timestamp.
The query type specifies the type of query to perform.
The query type can be LatestByVersion
, LatestByTs
, LastLessThanTs
,
LastLessOrEqualTs
, FirstGreaterOrEqualTs
or FirstGreaterThanTs
.