acid-state 0.6.5 → 0.6.6
raw patch · 4 files changed
+18/−7 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- acid-state.cabal +1/−1
- examples/HelloDatabase.hs +6/−5
- src/Data/Acid/Local.hs +1/−0
- src/Data/Acid/Log.hs +10/−1
acid-state.cabal view
@@ -7,7 +7,7 @@ -- The package version. See the Haskell package versioning policy -- (http://www.haskell.org/haskellwiki/Package_versioning_policy) for -- standards guiding when and how versions should be incremented.-Version: 0.6.5+Version: 0.6.6 -- A short (one-line) description of the package. Synopsis: Add ACID guarantees to any serializable Haskell data structure.
examples/HelloDatabase.hs view
@@ -32,9 +32,10 @@ main :: IO () main = do args <- getArgs database <- openLocalStateFrom "myDatabase/" (Database ["Welcome to the acid-state database."])- if null args- then do messages <- query database (ViewMessages 10)- putStrLn "Last 10 messages:"- mapM_ putStrLn [ " " ++ message | message <- messages ]- else do update database (AddMessage (unwords args))+ case args of+ [] -> do messages <- query database (ViewMessages 10)+ putStrLn "Last 10 messages:"+ mapM_ putStrLn [ " " ++ message | message <- messages ]+ ["checkpoint"] -> createCheckpoint database+ _ -> do update database (AddMessage (unwords args)) putStrLn "Your message has been added to the database."
src/Data/Acid/Local.hs view
@@ -198,6 +198,7 @@ eventsLog <- openFileLog eventsLogKey events <- readEntriesFrom eventsLog n mapM_ (runColdMethod core) events+ ensureLeastEntryId eventsLog n checkpointsLog <- openFileLog checkpointsLogKey stateCopy <- newIORef undefined withCoreState core (writeIORef stateCopy)
src/Data/Acid/Log.hs view
@@ -10,6 +10,7 @@ , closeFileLog , pushEntry , pushAction+ , ensureLeastEntryId , readEntriesFrom , rollbackTo , rollbackWhile@@ -152,6 +153,14 @@ = entry : worker next worker (Fail msg) = error msg +ensureLeastEntryId :: FileLog object -> EntryId -> IO ()+ensureLeastEntryId fLog youngestEntry = do+ atomically $ do+ entryId <- readTVar (logNextEntryId fLog)+ writeTVar (logNextEntryId fLog) (max entryId youngestEntry)+ cutFileLog fLog+ return ()+ -- Read all durable entries younger than the given EntryId. -- Note that entries written during or after this call won't -- be included in the returned list.@@ -232,7 +241,7 @@ | otherwise -- If 'left' starts after our maxEntryId then we're done. = [] ltMinEntryId = case minEntryIdMb of Nothing -> const False- Just minEntryId -> (< minEntryId)+ Just minEntryId -> (<= minEntryId) ltMaxEntryId = case maxEntryIdMb of Nothing -> const True Just maxEntryId -> (< maxEntryId) rangeStart (firstEntryId, _path) = firstEntryId