diff options
Diffstat (limited to 'src/Hakyll')
-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 |