dinostore/atomic
This module provides bindings to the Deno.AtomicOperation
API. Read more about it here.
Types
pub type AtomicOperation
Functions
pub fn check(
op: AtomicOperation,
key key: List(KeyPart),
versionstamp versionstamp: Option(String),
) -> AtomicOperation
Add a key-versionstamp check to the operation. If the versionstamp is None
,
the check will make sure the key-value pair does not already exist in the
database.
pub fn check_entry(
op: AtomicOperation,
entry: Entry,
) -> AtomicOperation
Add a check based on an Entry
’s key and versionstamp to the operation.
pub fn commit(
op: AtomicOperation,
) -> Promise(Result(String, Nil))
Commit the operation to the database. A return of Ok(versionstamp)
means
that the operation was successful and all checks passed; a return of
Error(Nil)
means that at least one check failed and no mutations were
made.
pub fn delete(
op: AtomicOperation,
key: List(KeyPart),
) -> AtomicOperation
Add to the operation a mutation that deletes the specified key if all checks pass during the commit.
pub fn new(conn: Connection) -> AtomicOperation
Create a new AtomicOperation
.
pub fn set(
op: AtomicOperation,
key key: List(KeyPart),
value value: a,
expiration expiration: Option(Int),
) -> AtomicOperation
Add to the operation a mutation that sets the value of the specified key to the specified value if all checks pass during the commit.
An expiration (time-to-live, or TTL) can be specified in milliseconds. The key will be deleted from the database at earliest after the specified number of milliseconds have elapsed. Once the duration has passed, the key may still be visible or some additional time. If an expiration is not specified, the key will not expire.