lmdb-simple-0.4.0.0: Simple API for LMDB

Safe HaskellTrustworthy
LanguageHaskell2010

Database.LMDB.Simple.DBRef

Description

This module provides a mutable variable DBRef that is similar in concept to IORef except that it is tied to a particular key that persists in an LMDB database.

Synopsis

Documentation

data DBRef mode a Source #

A DBRef is a reference to a particular key within an LMDB database. It may be empty (Nothing) if the key does not currently exist in the database, or it may contain a Just value corresponding to the key.

A DBRef may be ReadWrite or ReadOnly, depending on the environment within which it is created. Note that ReadOnly does not imply that the contained value will not change, since the LMDB database could be modified externally.

newDBRef :: Serialise k => Environment mode -> Database k a -> k -> IO (DBRef mode a) Source #

Create a new DBRef for the given key and database within the given environment.

readDBRef :: Serialise a => DBRef mode a -> IO (Maybe a) Source #

Read the current value of a DBRef.

writeDBRef :: Serialise a => DBRef ReadWrite a -> Maybe a -> IO () Source #

Write a new value into a DBRef.

modifyDBRef_ :: Serialise a => DBRef ReadWrite a -> (Maybe a -> Maybe a) -> IO () Source #

Atomically mutate the contents of a DBRef.

modifyDBRef :: Serialise a => DBRef ReadWrite a -> (Maybe a -> (Maybe a, b)) -> IO b Source #

Atomically mutate the contents of a DBRef and return a value.