vcache-0.1: large, persistent, memcached values and structure sharing for Haskell

Safe HaskellNone
LanguageHaskell2010

Database.VCache.VTx

Synopsis

Documentation

data VTx a Source

The VTx transactions allow developers to atomically manipulate PVars and STM resources (TVars, TArrays, etc..). VTx is a thin layer above STM, additionally tracking which PVars are written so it can push the batch to a background writer thread upon commit.

VTx supports full ACID semantics (atomic, consistent, isolated, durable), but durability is optional (see markDurable).

runVTx :: VSpace -> VTx a -> IO a Source

runVTx executes a transaction that may involve both STM TVars (via liftSTM) and VCache PVars (via readPVar, writePVar).

liftSTM :: STM a -> VTx a Source

run an arbitrary STM operation as part of a VTx transaction.

markDurable :: VTx () Source

Durability for a VTx transaction is optional: it requires an additional wait for the background thread to signal that it has committed content to the persistence layer. Due to how writes are batched, a durable transaction may share its wait with many other transactions that occur at more or less the same time.

Developers should mark a transaction durable only if necessary based on domain layer policies. E.g. for a shopping service, normal updates and views of the virtual shopping cart might not be durable while committing to a purchase is durable.

markDurableIf :: Bool -> VTx () Source

This variation of markDurable makes it easier to short-circuit complex computations to decide durability when the transaction is already durable. If durability is already marked, the boolean is not evaluated.