Limited exports from Ephemeral backend
Getty Ritter
8 years ago
1 |
module Database.Tansu.Backend.Ephemeral |
|
1 | module Database.Tansu.Backend.Ephemeral | |
2 | (withEphemeralDb) where | |
2 | 3 | |
3 | 4 | import Control.Concurrent.MVar |
4 | 5 | import Data.ByteString (ByteString) |
17 | 18 | ephemeralGet :: IORef Table -> ByteString -> IO (Maybe ByteString) |
18 | 19 | ephemeralGet table key = M.lookup key `fmap` readIORef table |
19 | 20 | |
20 | withEphemeralDatabase :: (Database -> IO a) -> IO a | |
21 | withEphemeralDatabase comp = do | |
21 | withEphemeralDb :: (Database -> IO a) -> IO a | |
22 | withEphemeralDb comp = do | |
22 | 23 | lock <- newMVar () |
23 | 24 | table <- newIORef M.empty |
24 | 25 | comp $ Database |