Skip to content
Haskell library for reading/writing CDBs
Haskell
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Database
LICENSE
README
Setup.hs
hs-cdb.cabal

README

hs-cdb is a library to read and write CDB files.

For more information on the CDB file format, please consult:
http://cr.yp.to/cdb.html

The reading interface
---------------------

cdbInit :: FilePath -> IO CDB

cdbGet :: (Packable k, Unpackable v) => CDB -> k -> Maybe v
cdbGetAll :: (Packable k, Unpackable v) => CDB -> k -> [v]
cdbHasKey :: (Packable k) => CDB -> k -> Bool
cdbCount :: (Packable k) => CDB -> k -> Int

What these do should be fairly straightforward. ByteString, [Word8], and
String are all instances of Packable and Unpackable, so you can lookup
by any of these and the appropriate type will be returned. hs-cdb uses
ByteStrings internally, so use these for optimum performance.

The writing interface
---------------------

cdbMake :: FilePath -> CDBMake -> IO ()

cdbAdd :: (Packable k, Packable v) => k -> v -> CDBMake
cdbAddMany :: (Packable k, Packable v) => [(k,v)] => CDBMake

Example:

cdbMake "my.cdb" $ do
  cdbAdd "foo" "data associated with foo"
  cdbAddMany [("bar", "bar1"), ("bar", "bar2")]

Adam
Something went wrong with that request. Please try again.