mutableFlowStore

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>(source)

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

Each mutation takes the caller's transaction handle T, which txContext adapts into a TxContext so the write can enlist on it and register its publish. Mutations are non-suspending and run on that transaction; on commit the store refreshes its cache and tryEmits the delta onto its stream. The stream's buffer is unbounded so the commit callback never suspends on backpressure; a permanently slow consumer therefore grows the buffer without bound (eventually OOM) rather than blocking the committer. store assigns each write's version; the blocking get read-through runs on the caller's thread, as the writes do. The suspending async operations and the valueFlow read-through instead run their blocking work on dispatcher (IO by default). V must be an aggregate root — see FlowStore.