-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathREADME
35 lines (24 loc) · 1.01 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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