A library for reading and writing CDB (Constant Database) files.
CDB files are immutable key-value stores, designed for extremely fast and memory-efficient construction and lookup. They can be as large as 4GB, and at no point in their construction or use must all data be loaded into memory. CDB files can contain multiple values for a given key.
For more information on the CDB file format, please see: http://cr.yp.to/cdb.html
Here's how you make new CDB file:
import qualified Data.ByteString.Char8 as B import Database.PureCDB makeIt :: IO () makeIt = makeCDB (do addBS (B.pack "foo") (B.pack "bar") addBS (B.pack "foo") (B.pack "baz")) "foo.cdb"
You can later use it as in:
getIt :: IO [ByteString] getIt = do f <- openCDB "foo.cdb" getBS f (B.pack "foo") closeCDB "foo.cdb"
getIt returns [ "bar", "baz" ] in unspecified order.
pure-cdb works on strict
ByteString's only for now.
Write context monad transformer.
Runs WriteCDB monad transformer to make the database.
Adds key and value to the CDB database.