diff options
author | noxx <noxx@noxx-inferno.(none)> | 2013-05-04 12:51:58 +0300 |
---|---|---|
committer | noxx <noxx@noxx-inferno.(none)> | 2013-05-04 12:51:58 +0300 |
commit | a3021bc703d8a60a2e6467afce6691ee039f3612 (patch) | |
tree | b225ee38dd8fdbde925e9becf4dc6e92573dbf71 | |
parent | 4100083709a894225717dbe3068f73057e908dd6 (diff) | |
download | hakyll-a3021bc703d8a60a2e6467afce6691ee039f3612.tar.gz |
Added isMember functions for Store
-rw-r--r-- | src/Hakyll/Core/Store.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Store.hs b/src/Hakyll/Core/Store.hs index 1208c84..eb2d742 100644 --- a/src/Hakyll/Core/Store.hs +++ b/src/Hakyll/Core/Store.hs @@ -9,6 +9,7 @@ module Hakyll.Core.Store , new , set , get + , isMember , delete , hash ) where @@ -101,6 +102,16 @@ cacheLookup (Store _ (Just lru)) key = do -------------------------------------------------------------------------------- +cacheIsMember :: Store -> String -> Bool +cacheIsMember (Store _ Nothing) _ = False +cacheIsMember (Store _ (Just lru)) key = + let res = Lru.lookup key lru in + case Just res of + Nothing -> False + _ -> True + + +-------------------------------------------------------------------------------- -- | Auxiliary: delete an item from the in-memory cache cacheDelete :: Store -> String -> IO () cacheDelete (Store _ Nothing) _ = return () @@ -152,6 +163,17 @@ get store identifier = do -------------------------------------------------------------------------------- +-- | Strict function +isMember :: Store -> [String] -> IO Bool +isMember store identifier + | cacheIsMember store key = return True + | otherwise = doesFileExist path + + where + key = hash identifier + path = storeDirectory store </> key + +-------------------------------------------------------------------------------- -- | Delete an item delete :: Store -> [String] -> IO () delete store identifier = do |