ttl-hashtables 1.3.1.0 → 1.3.1.1
raw patch · 2 files changed
+11/−6 lines, 2 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.TTLHashTable: delete :: (HashTable h, Eq k, Hashable k, MonadIO m) => TTLHashTable h k v -> k -> m ()
+ Data.TTLHashTable: delete :: (HashTable h, Eq k, Hashable k, MonadIO m, Failable m) => TTLHashTable h k v -> k -> m ()
Files
- src/Data/TTLHashTable.hs +8/−3
- ttl-hashtables.cabal +3/−3
src/Data/TTLHashTable.hs view
@@ -56,7 +56,7 @@ import Prelude hiding (lookup) import Control.Exception (Exception)-import Control.Monad (void, when)+import Control.Monad (void, forM_, when) import Control.Monad.Except (runExcept, throwError) import Control.Monad.Failable (Failable, failure) import Control.Monad.IO.Class (MonadIO, liftIO)@@ -297,8 +297,13 @@ runMaybeT $ lookup ht k -- | delete an entry from the hash table.-delete :: (C.HashTable h, Eq k, Hashable k, MonadIO m) => TTLHashTable h k v -> k -> m ()-delete = ((.).(.)) (void . runMaybeT) (mutateWith (\_ -> (Nothing, ())))+delete :: (C.HashTable h, Eq k, Hashable k, MonadIO m, Failable m) =>+ TTLHashTable h k v -> k -> m ()+delete ht@TTLHashTable {..} k = do+ timeStamp <- deleteWith $ \v ->+ (Nothing, v >>= return . expiresAt)+ forM_ timeStamp $ liftIO . modifyIORef' timeStampsRef_ . M.delete+ where deleteWith fun = mutateWith fun ht k deleteExpired :: Int -> Maybe (Value v) -> (Maybe (Value v), Maybe ()) deleteExpired _ Nothing =
ttl-hashtables.cabal view
@@ -1,13 +1,13 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: 4cf4013135bc349c8a88c7f4fb34b7ee74367cf2d35e46f5404bdc4f9dbeb1cb+-- hash: d0820b75d28abc8c49166e916af08aad52803d220fa263f44b784425e46411e7 name: ttl-hashtables-version: 1.3.1.0+version: 1.3.1.1 synopsis: Extends hashtables so that entries added can be expired after a TTL description: This library extends fast mutable hashtables so that entries added can be expired after a given TTL (time to live). This TTL can be specified as a default property of the table or on a per entry basis. category: Data