Package-level declarations

Types

Link copied to clipboard
interface AsyncFlowStore<K : Any, V : Any>

Suspending view of a FlowStore: get runs the blocking read-through on the store's dispatcher, short-circuiting a cache hit inline so only a miss is dispatched.

Link copied to clipboard

Suspending view of a MutableFlowStore: each call dispatches its blocking work to the store's dispatcher. The mutations take the caller's transaction handle T, so use this where T tolerates use from the dispatcher (a transaction managed across threads with serial access); where the transaction is driven by a thread-bound, non-suspending callback, use the non-suspending MutableFlowStore instead.

Link copied to clipboard
interface FlowStore<K : Any, V : Any>

Read view of a store-backed map. Exposes the delta stream and per-key access only; there is no full-map snapshot, so values are read through to the store on a miss.

Link copied to clipboard
interface MutableFlowStore<K : Any, V : Any, T> : FlowStore<K, V>

Read/write view of a store-backed map. Every mutation takes the caller's transaction handle T: the write is enlisted on it through StoreWriter, which assigns the version, and the cache update and delta are published only when that transaction commits.

Link copied to clipboard
interface Store<K : Any, V : Any, T> : StoreReader<K, V> , StoreWriter<K, V, T>

Combines StoreReader and StoreWriter for a backend that implements both.

Link copied to clipboard
interface StoreReader<K : Any, V : Any>

Read half of the store SPI.

Link copied to clipboard
interface StoreWriter<K : Any, V : Any, T>

Write half of the store SPI. Implementations enlist on TxContext.transaction and must not commit the transaction themselves. Each write assigns and returns the new version from the store's commit order (a sequence, identity, or version column); the caller never supplies it.

Link copied to clipboard
interface TxContext<out T>

A driver-agnostic unit of work. transaction is the underlying transaction handle. The owner of the transaction begins and commits it; callers only register post-commit side-effects via onCommitEnd (and optional onRollback cleanup), which run inside a synchronous commit/rollback callback.

Link copied to clipboard
class Versioned<out V : Any>(val value: V, val version: Long)

A value paired with the monotonically increasing version it was written at.

Functions

Link copied to clipboard
fun <K : Any, V : Any> flowStore(reader: StoreReader<K, V>, inbound: Flow<VersionedMapEvent<K, V>>, caffeine: Caffeine<Any, Any>, scope: CoroutineScope, dispatcher: CoroutineDispatcher = Dispatchers.IO, bufferCapacity: Int = DEFAULT_SIGNAL_BUFFER): FlowStore<K, V>

Creates a read-only FlowStore consumer fed by an inbound delta stream (the owner's published mutations) and reading reader on a cache miss. The collection of inbound is launched in scope, so cancelling scope stops it and a failure of inbound surfaces through scope (its parent / exception handler), after which the store serves only stale reads. The hot set is a Caffeine cache built from caffeine (size it to bound memory). The blocking read-through load runs on dispatcher (IO by default). V must be an aggregate root — see FlowStore.

Link copied to clipboard
fun <K : Any, V : Any> Flow<VersionedMapEvent<K, V>>.flowStoreIn(reader: StoreReader<K, V>, caffeine: Caffeine<Any, Any>, scope: CoroutineScope, dispatcher: CoroutineDispatcher = Dispatchers.IO, bufferCapacity: Int = DEFAULT_SIGNAL_BUFFER): FlowStore<K, V>

Operator form of flowStore, reading this delta stream as the inbound source: deltas .flowStoreIn(reader, caffeine, scope). Mirrors shareIn/stateIn — collection is launched in scope and the returned FlowStore is the read-only consumer. See flowStore for the lifecycle, caching, and dispatcher semantics.

Link copied to clipboard
fun <K : Any, V : Any, T> mutableFlowStore(store: Store<K, V, T>, caffeine: Caffeine<Any, Any>, dispatcher: CoroutineDispatcher = Dispatchers.IO, txContext: (T) -> TxContext<T>): MutableFlowStore<K, V, T>

Creates a MutableFlowStore backed by store, with a bounded hot set built from caffeine (size it to bound memory).