haskey-0.3.0.2: A transactional, ACID compliant, embeddable key-value store.

Safe HaskellNone
LanguageHaskell2010

Database.Haskey.Store.File

Contents

Description

On-disk storage back-end. Can be used as a storage back-end for the append-only page allocator (see Data.BTree.Alloc).

Synopsis

Storage

data Page (t :: PageType) where Source #

A decoded page, of a certain type t of kind PageType.

data FileStoreConfig Source #

File store configuration.

The default configuration can be obtained by using defFileStoreConfig

A configuration with a specific page size can be obtained by using fileStoreConfigWithPageSize.

defFileStoreConfig :: FileStoreConfig Source #

The default configuration

This is an unwrapped fileStoreConfigWithPageSize with a page size of 4096 bytes.

fileStoreConfigWithPageSize :: PageSize -> Maybe FileStoreConfig Source #

Create a configuration with a specific page size.

The maximum key and value sizes are calculated using calculateMaxKeySize and calculateMaxValueSize.

If the page size is too small, Nothing is returned.

data FileStoreT fp m a Source #

Monad in which on-disk storage operations can take place.

Two important instances are StoreM making it a storage back-end, and ConcurrentMetaStoreM making it a storage back-end compatible with the concurrent page allocator.

Instances

Monad m => MonadReader FileStoreConfig (FileStoreT fp m) Source # 
(Applicative m, Monad m, MonadIO m, MonadThrow m) => StoreM FilePath (FileStoreT FilePath m) Source # 
Monad m => Monad (FileStoreT fp m) Source # 

Methods

(>>=) :: FileStoreT fp m a -> (a -> FileStoreT fp m b) -> FileStoreT fp m b #

(>>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

return :: a -> FileStoreT fp m a #

fail :: String -> FileStoreT fp m a #

Functor m => Functor (FileStoreT fp m) Source # 

Methods

fmap :: (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

(<$) :: a -> FileStoreT fp m b -> FileStoreT fp m a #

Monad m => Applicative (FileStoreT fp m) Source # 

Methods

pure :: a -> FileStoreT fp m a #

(<*>) :: FileStoreT fp m (a -> b) -> FileStoreT fp m a -> FileStoreT fp m b #

liftA2 :: (a -> b -> c) -> FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m c #

(*>) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m b #

(<*) :: FileStoreT fp m a -> FileStoreT fp m b -> FileStoreT fp m a #

MonadIO m => MonadIO (FileStoreT fp m) Source # 

Methods

liftIO :: IO a -> FileStoreT fp m a #

MonadThrow m => MonadThrow (FileStoreT fp m) Source # 

Methods

throwM :: Exception e => e -> FileStoreT fp m a #

MonadCatch m => MonadCatch (FileStoreT fp m) Source # 

Methods

catch :: Exception e => FileStoreT fp m a -> (e -> FileStoreT fp m a) -> FileStoreT fp m a #

MonadMask m => MonadMask (FileStoreT fp m) Source # 

Methods

mask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

uninterruptibleMask :: ((forall a. FileStoreT fp m a -> FileStoreT fp m a) -> FileStoreT fp m b) -> FileStoreT fp m b #

generalBracket :: FileStoreT fp m a -> (a -> ExitCase b -> FileStoreT fp m c) -> (a -> FileStoreT fp m b) -> FileStoreT fp m (b, c) #

(Applicative m, Monad m, MonadIO m, MonadCatch m) => ConcurrentMetaStoreM (FileStoreT FilePath m) Source # 

runFileStoreT Source #

Arguments

:: Monad m 
=> FileStoreT FilePath m a

Action

-> FileStoreConfig

Configuration

-> m a 

Run the storage operations in the FileStoreT monad, given a collection of open files.

Binary encoding

encodeAndPad :: PageSize -> Page t -> Maybe ByteString Source #

Encode a page padding it to the maxim page size.

Return Nothing of the page is too large to fit into one page size.

Exceptions

newtype FileNotFoundError hnd Source #

Exception thrown when a file is accessed that doesn't exist.

Constructors

FileNotFoundError hnd