Unit of Work
In one line: the unit of durability — it groups one or more transactions into a single flush cycle and decides, via its
DurabilityMode, when their commits become crash-safe.
Typhon splits "what's atomic" from "what's durable". A transaction is atomic and isolated; a UnitOfWork is the durability boundary that wraps it. Durability is a batched, cross-cutting concern — one fsync can make many transactions durable at once — so it lives one level up from the transaction.
A committed transaction is visible immediately, but only becomes durable when its UoW flushes — on the schedule set by its DurabilityMode. Under the runtime, there is exactly one UoW per tick.
How it relates
- Transaction — what a UoW contains; visibility is the transaction's job, durability is the UoW's.
- Durability — mode & discipline — the UoW's
DurabilityModeis the when-does-the-WAL-flush dial. - The tick — the runtime opens one UoW per tick and flushes it at tick end.
- Snapshot isolation — visibility advances independently of the UoW's flush.
In the API
UnitOfWork— the type itself;CreateTransaction(...),Flush()/FlushAsync().DatabaseEngine—CreateUnitOfWork(DurabilityMode).DurabilityMode— the flush-timing enum set at UoW creation.
Learn & use
- Narrative: Guide ch.3 §1 — two layers
- Reference: Isolation & durability cheat sheet
- Feature detail: Unit of Work · durability modes