acid-state-0.11.4: Add ACID guarantees to any serializable Haskell data structure.

Portability | non-portable (uses GHC extensions)
Maintainer | lemmih@gmail.com
Safe Haskell | None

Data.Acid.Local

Description

AcidState container using a transaction log on disk. The term 'Event' is loosely used for transactions with ACID guarantees. 'Method' is loosely used for state operations without ACID guarantees (see Data.Acid.Core).

Synopsis

- openLocalState :: (Typeable st, IsAcidic st) => st -> IO (AcidState st)
- openLocalStateFrom :: IsAcidic st => FilePath -> st -> IO (AcidState st)
- prepareLocalState :: (Typeable st, IsAcidic st) => st -> IO (IO (AcidState st))
- prepareLocalStateFrom :: IsAcidic st => FilePath -> st -> IO (IO (AcidState st))
- createArchive :: AcidState st -> IO ()
- createCheckpointAndClose :: SafeCopy st => AcidState st -> IO ()

# Documentation

openLocalState Source

Arguments

:: (Typeable st, IsAcidic st) |
=> st | Initial state value. This value is only used if no checkpoint is found.
-> IO (AcidState st) |

Create an AcidState given an initial value.

This will create or resume a log found in the "state/[typeOf state]/" directory.

openLocalStateFrom Source

Arguments

:: IsAcidic st |
=> FilePath | Location of the checkpoint and transaction files.
-> st | Initial state value. This value is only used if no checkpoint is found.
-> IO (AcidState st) |

Create an AcidState given a log directory and an initial value.

This will create or resume a log found in `directory`. Running two AcidState's from the same directory is an error but will not result in dataloss.

prepareLocalState Source

Arguments

:: (Typeable st, IsAcidic st) |
=> st | Initial state value. This value is only used if no checkpoint is found.
-> IO (IO (AcidState st)) |

Create an AcidState given an initial value.

This will create or resume a log found in the "state/[typeOf state]/" directory. The most recent checkpoint will be loaded immediately but the AcidState will not be opened until the returned function is executed.

prepareLocalStateFrom Source

Arguments

:: IsAcidic st |
=> FilePath | Location of the checkpoint and transaction files.
-> st | Initial state value. This value is only used if no checkpoint is found.
-> IO (IO (AcidState st)) |

Create an AcidState given an initial value.

This will create or resume a log found in `directory`. The most recent checkpoint will be loaded immediately but the AcidState will not be opened until the returned function is executed.

createArchive :: AcidState st -> IO ()Source

Move all log files that are no longer necessary for state restoration into the `Archive` folder in the state directory. This folder can then be backed up or thrown out as you see fit. Reverting to a state before the last checkpoint will not be possible if the `Archive` folder has been thrown out.

This method is idempotent and does not block the normal operation of the AcidState.

createCheckpointAndClose :: SafeCopy st => AcidState st -> IO ()Source

Save a snapshot to disk and close the AcidState as a single atomic action. This is useful when you want to make sure that no events are saved to disk after a checkpoint.