-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Cache for HXT XML Documents and other binary data
--
-- Extension for caching XML documents and other binary data in cache
-- directory of the local filesystem. The module exports a version of
-- readDocument with the additional cache functionality.
@package hxt-cache
@version 0.0.5
module Control.Concurrent.ResourceTable
type ResourceTable a = MVar (Map a ResourceLock)
type ResourceLock = (MVar (), Int)
requestResource :: (Ord a) => ResourceTable a -> a -> IO ()
releaseResource :: (Ord a) => ResourceTable a -> a -> IO ()
newResourceTable :: IO (ResourceTable a)
-- | Caching of XML document trees and other binary data
module Text.XML.HXT.Arrow.XmlCache
-- | This readDocument is a wrapper for the
-- Text.XML.HXT.Arrow.ReadDocument.readDocument function. The
-- function is controlled by the options a_cache,
-- a_compress and a_document_age.
--
--
-- - a_cache: the document tree of the document read is cached
-- in the directory given by this option, or, if it is read before and it
-- is not out of date, see a_document_age, it is read from the
-- cache. The document is stored in binary format (used package:
-- binary).
-- - a_compress : controls whether the cache contents is
-- compressed with the bzip2 lib for saving space
-- - a_document_age: determines the maximum age of the document
-- in seconds. If this time is exceeded, the cache entry is ignored, the
-- original is re-read and cached again. Default for the document age is
-- 1 day.
-- - a_cache_404 : If set, cache is activated even for 404 (not
-- found) responses, default is false.
--
readDocument :: Attributes -> String -> IOStateArrow s b XmlTree
a_cache :: String
a_compress :: String
a_document_age :: String
a_cache_404 :: String
lookupCache :: (NFData b, Binary b) => CacheConfig -> String -> IOStateArrow s a b
writeCache :: (Binary b) => CacheConfig -> String -> IOStateArrow s b ()
-- | Compute the SHA1 hash is hexadecimal format for an arbitray
-- serializable value
sha1HashValue :: (Arrow a, Binary b) => a b Integer
sha1HashString :: (Arrow a, Binary b) => a b String
data CacheConfig
CC :: FilePath -> Bool -> Integer -> Bool -> CacheConfig
c_dir :: CacheConfig -> FilePath
c_compress :: CacheConfig -> Bool
c_age :: CacheConfig -> Integer
c_404 :: CacheConfig -> Bool
-- | Arrow for checking if a document is in the cache. The arrow fails if
-- document not there, else the file modification time is returned.
isInCache :: Attributes -> IOStateArrow s String ClockTime
isInCache' :: CacheConfig -> String -> IO (Maybe ClockTime)