gdritter repos tansu-berkeleydb / 14309c0
Renamed Database->TansuDB Getty Ritter 8 years ago
1 changed file(s) with 6 addition(s) and 6 deletion(s). Collapse all Expand all
44 import Data.ByteString (ByteString)
55 import System.Directory (createDirectoryIfMissing)
66
7 import Database.Tansu.Internal (Database(..))
7 import Database.Tansu.Internal (TansuDb(..))
88
99 bdbSet :: Db -> ByteString -> ByteString -> IO ()
1010 bdbSet db key val =
1414 bdbGet db key =
1515 db_get [] db Nothing key
1616
17 withBerkeleyDb :: FilePath -> (Database -> IO a) -> IO a
17 withBerkeleyDb :: FilePath -> (TansuDb -> IO a) -> IO a
1818 withBerkeleyDb path comp = do
1919 createDirectoryIfMissing True path
2020 env <- dbEnv_create []
2121 dbEnv_open [DB_CREATE,DB_INIT_MPOOL,DB_INIT_TXN] 0 env path
2222 db <- db_create [] env
2323 db_open [DB_CREATE] DB_HASH 0 db Nothing path Nothing
24 result <- comp $ Database { dbGet = bdbGet db
25 , dbSet = bdbSet db
26 , dbRunTransaction = id
27 }
24 result <- comp $ TansuDb { dbGet = bdbGet db
25 , dbSet = bdbSet db
26 , dbRunTransaction = id
27 }
2828 db_close [] db
2929 dbEnv_close [] env
3030 return result