(begin-tx kvs)Start a transaction: pin the snapshot seq, register it in the active set (so the GC floor preserves the versions it can see), and start with an empty write-set.
The snapshot is pinned to applied -- the max seq the memtable has actually
applied -- NOT current-seq. Every seq <= applied is materializable by the
read path, so tx-get always sees a consistent snapshot; a seq assigned but not
yet applied is not externally committed (commits block until apply), so leaving
it out is correct, not stale. Pin + register happen under the commit lock (the
version pin and lock are unchanged); the floor is only made more conservative,
since applied snapshots are <= the old current-seq ones (see Bug-2 spec).
Start a transaction: pin the snapshot seq, register it in the active set (so the GC floor preserves the versions it can see), and start with an empty write-set. The snapshot is pinned to `applied` -- the max seq the memtable has actually applied -- NOT `current-seq`. Every seq <= `applied` is materializable by the read path, so `tx-get` always sees a consistent snapshot; a seq assigned but not yet applied is not externally committed (commits block until apply), so leaving it out is correct, not stale. Pin + register happen under the commit lock (the version pin and lock are unchanged); the floor is only made more conservative, since applied snapshots are <= the old current-seq ones (see Bug-2 spec).
(close! kvs)Shut the store down: reject further writes, then stop the background workers.
Explicit shutdown (rather than an Object.finalize hook -- GC finalization is
unreliable and unsupported under Babashka's SCI records).
Closing marks the store unusable via the same poison atom used for fail-stop
(with a :closed marker instead of a fault), so every subsequent operation --
write!/delete! and select/scan -- fails fast with a clear "store is
closed" error, and any stalled writer is woken (the poison watch fires).
compare-and-set! leaves an existing fault in place so a poisoned-then-closed
store still reports its original cause.
close! is synchronous: after signaling shutdown it JOINS the background workers
(each worker's channel closes when it exits), so once close! returns no flush or
compaction thread is still reading/writing SSTable or WAL files -- a caller may
safely delete the data directory immediately.
Shut the store down: reject further writes, then stop the background workers. Explicit shutdown (rather than an `Object.finalize` hook -- GC finalization is unreliable and unsupported under Babashka's SCI records). Closing marks the store unusable via the same `poison` atom used for fail-stop (with a `:closed` marker instead of a fault), so every subsequent operation -- `write!`/`delete!` and `select`/`scan` -- fails fast with a clear "store is closed" error, and any stalled writer is woken (the poison watch fires). `compare-and-set!` leaves an existing fault in place so a poisoned-then-closed store still reports its original cause. `close!` is synchronous: after signaling shutdown it JOINS the background workers (each worker's channel closes when it exits), so once `close!` returns no flush or compaction thread is still reading/writing SSTable or WAL files -- a caller may safely delete the data directory immediately.
(commit-tx tx)Commit the transaction. An empty write-set (a read-only tx) is a no-op. Otherwise
the whole write-set goes through the commit-handler at the tx's snapshot seq
(write-write conflict detection, first-committer-wins). Returns :committed; on a
conflict throws an ex-info tagged :igeldb/conflict (retriable) that the caller
may catch to retry -- the tx is rolled back (deregistered) either way. The snapshot
is always deregistered exactly once. Rejects a finished transaction.
Commit the transaction. An empty write-set (a read-only tx) is a no-op. Otherwise the whole write-set goes through the commit-handler at the tx's snapshot seq (write-write conflict detection, first-committer-wins). Returns `:committed`; on a conflict throws an ex-info tagged `:igeldb/conflict` (retriable) that the caller may catch to retry -- the tx is rolled back (deregistered) either way. The snapshot is always deregistered exactly once. Rejects a finished transaction.
(delete! kvs k)Delete the given key from the key-value store.
Delete the given key from the key-value store.
(gen-kvs config-path)Open an IgelDB store from config-path.
The configured SSTable and WAL directories are held with exclusive filesystem
locks until close! returns. If either directory is already owned by another
IgelDB instance or process, throws an ex-info tagged
:igeldb/directory-locked.
Open an IgelDB store from `config-path`. The configured SSTable and WAL directories are held with exclusive filesystem locks until `close!` returns. If either directory is already owned by another IgelDB instance or process, throws an ex-info tagged `:igeldb/directory-locked`.
(rollback-tx tx)Abort the transaction: discard the buffered write-set and deregister the snapshot. Rejects a finished transaction.
Abort the transaction: discard the buffered write-set and deregister the snapshot. Rejects a finished transaction.
(scan kvs from-key to-key)Read the key-value pairs between the from-key and the to-key.
This range should include from-key and not include to-key.
It returns key-value pair vectors like [[k0 v0] [k1 v1]].
The keys should be ordered by ascending.
Read the key-value pairs between the `from-key` and the `to-key`. This range should include `from-key` and not include `to-key`. It returns key-value pair vectors like [[k0 v0] [k1 v1]]. The keys should be ordered by ascending.
(select kvs k)Read the value corresponding to the given key. If the key doesn't exist, it returns nil.
Read the value corresponding to the given key. If the key doesn't exist, it returns nil.
(tx-delete tx k)Buffer a delete of k into the tx's write-set (a tombstone). Not durable until
commit-tx. Rejects a finished transaction.
Buffer a delete of `k` into the tx's write-set (a tombstone). Not durable until `commit-tx`. Rejects a finished transaction.
(tx-get tx k)Read k inside the tx: the tx's own buffered write wins (read-your-writes),
otherwise the store at the tx's snapshot seq. Returns the value bytes, or nil for
an absent key or the tx's own tombstone. Rejects a finished transaction.
Read `k` inside the tx: the tx's own buffered write wins (read-your-writes), otherwise the store at the tx's snapshot seq. Returns the value bytes, or nil for an absent key or the tx's own tombstone. Rejects a finished transaction.
(tx-put tx k v)Buffer a write of k=v into the tx's write-set (folding an earlier write of
the same key). Not durable until commit-tx. Rejects a finished transaction.
Buffer a write of `k`=`v` into the tx's write-set (folding an earlier write of the same key). Not durable until `commit-tx`. Rejects a finished transaction.
(with-tx [tx-sym kvs] & body)Run body in a transaction bound to tx-sym: begin, evaluate the body, then
commit on normal completion (returning the body's value) or roll back if the body
throws (re-throwing). A commit conflict throws an :igeldb/conflict ex-info out of
with-tx; it is NOT auto-retried -- catch it to retry the whole transaction.
Run `body` in a transaction bound to `tx-sym`: begin, evaluate the body, then commit on normal completion (returning the body's value) or roll back if the body throws (re-throwing). A commit conflict throws an `:igeldb/conflict` ex-info out of `with-tx`; it is NOT auto-retried -- catch it to retry the whole transaction.
(write! kvs k v)Write the new value correponding to the given key.
Write the new value correponding to the given key.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |