perdure-0.2.0: Robust persistence for acyclic immutable data

Safe HaskellNone

Database.Perdure

Synopsis

Documentation

data LocalStoreFile Source

A file or raw device where we can persist bytes.

withRawDeviceStoreFiles :: [FilePath] -> ([LocalStoreFile] -> IO a) -> ErrorT String IO aSource

Like nesting multiple calls to withRawDeviceStoreFile.

withRawDeviceStoreFile :: FilePath -> (LocalStoreFile -> IO a) -> ErrorT String IO aSource

Opens the specified raw device as a LocalStoreFile, runs the provided function and closes the device. Do not make concurrent calls on the same device, place concurrency in the passed function.

withFileStoreFile :: FilePath -> (LocalStoreFile -> IO a) -> ErrorT String IO aSource

Opens the specified file as a LocalStoreFile, runs the provided function and closes the file. Do not make concurrent calls on the same file, place concurrency in the passed function.

newtype ReplicatedFile Source

A list of LocalStoreFile to be used as replicates. We write to all replicates and read from the first one that reports no error.

newCachedFile :: Integer -> ReplicatedFile -> IO CachedFileSource

Wraps a ReplicatedFile with cache of a given size (number of dereferenced DRefs)

data RootLocation Source

The RootLocation specifies where roots are written, and provides a cache.

defaultRootLocation :: CachedFile -> RootLocationSource

At the moment this is the only way to create a rootLocation. The root of the database will be located in one of two reserved locations at the start of the specified files.

data PVar s Source

Represents a persisted database. Contains a (ram-only) lock to sequence multithreaded operations, so only one PVar must be created per RootLocation.

openPVar :: (Typeable s, Persistent s) => RootLocation -> IO (Maybe (PVar s))Source

Attempts to open a PVar by reading at the given RootLocation. Do not open the same location multiple times, share the PVar instead.

createPVar :: (Typeable s, Persistent s) => s -> Word64 -> RootLocation -> IO (PVar s)Source

Creates a PVar with the specified initial state. Writes at the specified location, using the given maximum usable space (in bytes).

updatePVar :: (Typeable s, Persistent s) => PVar s -> StateT s IO a -> IO aSource

Persist a state change

updateInspectPVar :: (Typeable s, Persistent s) => PVar s -> StateT s (ReaderT (PState s) IO) a -> IO aSource

This function allows read access to the bookkeeping structures of the database. The PState type is subject to change.