muesli-0.1.1.0: A simple document-oriented database

Copyright(c) 2015 Călin Ardelean
LicenseMIT
MaintainerCălin Ardelean <calinucs@gmail.com>
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Database.Muesli.Handle

Description

Database resource management.

Synopsis

Documentation

data Handle l Source

Handle used for database management operations.

The l parameter stands for a LogState backend.

Instances

open Source

Arguments

:: (MonadIO m, LogState l) 
=> Maybe DbPath

Log path. Default is data/docdb.log.

-> Maybe DbPath

Data path. Default is data/docdb.dat.

-> Maybe (Int, Int, NominalDiffTime)

LRUCache parameters: (min cap in bytes, max cap in bytes, max age in seconds). Defaults are: (1MB, 10MB, 1min).

-> Maybe Int

Commit delay in microseconds. Default is 100ms.

-> m (Handle l) 

Opens a database, reads the transaction log and builds the in-memory indexes.

The l parameter of the resulting Handle should be instantiated by the user in order to specify a backend. For example, to use the file backend:

import qualified Database.Muesli.Handle as DB

openDataBase :: FilePath -> FilePath -> IO (DB.Handle DB.FileLogState)
openDataBase logPath dataPath = open (Just logPath) (Just dataPath) Nothing Nothing

close :: (MonadIO m, LogState l) => Handle l -> m () Source

Closes the database.

Since the database is ACID, calling close is not really necessary for consistency purposes.

performGC :: MonadIO m => Handle l -> m () Source

Sends a message to the gcThread requesting GC.

debug Source

Arguments

:: (MonadIO m, LogState l) 
=> Handle l 
-> Bool

Dump indexes.

-> Bool

Dump the cache.

-> m String 

A debug function that traces the internal DBState.