A read-write transaction.
Start one with Slap.SlateDB.begin/2 or, more simply, Slap.SlateDB.transaction/3.
Reads see the database as of the start of the transaction plus the
transaction's own writes. Writes stay in memory until commit/2.
A transaction belongs to the process that uses it. Do not use it from more than one process at the same time.
Summary
Functions
Commits the transaction.
Adds a delete to the transaction.
Reads key, including this transaction's uncommitted writes. Takes the
options of Slap.SlateDB.get/3.
Reads key with its metadata, like Slap.SlateDB.get_key_value/3,
including this transaction's uncommitted writes. Their :seq is nil until
commit.
Opens an iterator over the transaction's rows. See Slap.SlateDB.iterator/2.
Adds a merge operand to the transaction. The database must be opened with a
:merge_operator; see Slap.SlateDB.merge/4. Takes the :ttl option of put/4.
Adds a put to the transaction.
Throws away the transaction's writes. Rolling back twice is allowed.
Scans rows, including this transaction's uncommitted writes. With
with_versions: true, those writes have a nil version. See
Slap.SlateDB.scan/2.
Types
Functions
@spec commit(t(), keyword()) :: {:ok, non_neg_integer() | nil} | {:error, Slap.SlateDB.Error.t()}
Commits the transaction.
Returns {:ok, seq} with the commit's sequence number, or {:ok, nil} if
the transaction made no writes. Returns
{:error, %Slap.SlateDB.Error{kind: :conflict}} if the transaction conflicts
with another one that committed first.
Options
:await_durable- whentrue, returns only after the writes are durable in object storage. Defaults tofalse.:timeout- seeSlap.SlateDB.get/3.
@spec delete(t(), binary()) :: :ok | {:error, Slap.SlateDB.Error.t()}
Adds a delete to the transaction.
@spec get(t(), binary(), keyword()) :: {:ok, binary() | nil} | {:error, Slap.SlateDB.Error.t()}
Reads key, including this transaction's uncommitted writes. Takes the
options of Slap.SlateDB.get/3.
@spec get_key_value(t(), binary(), keyword()) :: {:ok, Slap.SlateDB.key_value() | nil} | {:error, Slap.SlateDB.Error.t()}
Reads key with its metadata, like Slap.SlateDB.get_key_value/3,
including this transaction's uncommitted writes. Their :seq is nil until
commit.
@spec iterator(t(), keyword()) :: {:ok, Slap.SlateDB.Iterator.t()} | {:error, Slap.SlateDB.Error.t()}
Opens an iterator over the transaction's rows. See Slap.SlateDB.iterator/2.
@spec merge(t(), binary(), binary(), keyword()) :: :ok | {:error, Slap.SlateDB.Error.t()}
Adds a merge operand to the transaction. The database must be opened with a
:merge_operator; see Slap.SlateDB.merge/4. Takes the :ttl option of put/4.
@spec put(t(), binary(), binary(), keyword()) :: :ok | {:error, Slap.SlateDB.Error.t()}
Adds a put to the transaction.
Options
:ttl- time to live in milliseconds. By default, the database'sdefault_ttl_millissetting applies.
@spec rollback(t()) :: :ok
Throws away the transaction's writes. Rolling back twice is allowed.
@spec scan(t(), keyword()) :: Enumerable.t()
Scans rows, including this transaction's uncommitted writes. With
with_versions: true, those writes have a nil version. See
Slap.SlateDB.scan/2.