cached-io-1.1.0.0: A simple library to cache a single IO action with timeout
Safe HaskellSafe-Inferred
LanguageHaskell2010

Control.Concurrent.CachedIO

Synopsis

Documentation

cachedIO Source #

Arguments

:: (MonadIO m, MonadIO t, MonadCatch t) 
=> NominalDiffTime

Number of seconds before refreshing cache

-> t a

IO action to cache

-> m (t a) 

Cache an IO action, producing a version of this IO action that is cached for interval seconds. The cache begins uninitialized.

The outer IO is responsible for setting up the cache. Use the inner one to either get the cached value or refresh, if the cache is older than interval seconds.

cachedIOWith Source #

Arguments

:: (MonadIO m, MonadIO t, MonadCatch t) 
=> (UTCTime -> UTCTime -> Bool)

Test function: If isCacheStillFresh lastUpdated now returns True the cache is considered still fresh and returns the cached IO action

-> t a

action to cache.

-> m (t a) 

Cache an IO action, The cache begins uninitialized.

The outer IO is responsible for setting up the cache. Use the inner one to either get the cached value or refresh

cachedIO' Source #

Arguments

:: (MonadIO m, MonadIO t, MonadCatch t) 
=> NominalDiffTime

Number of seconds before refreshing cache

-> (Maybe (UTCTime, a) -> t a)

action to cache. The stale value and its refresh date are passed so that the action can perform external staleness checks

-> m (t a) 

Cache an IO action, producing a version of this IO action that is cached for interval seconds. The cache begins uninitialized.

The outer IO is responsible for setting up the cache. Use the inner one to either get the cached value or refresh, if the cache is older than interval seconds.

cachedIOWith' Source #

Arguments

:: (MonadIO m, MonadIO t, MonadCatch t) 
=> (UTCTime -> UTCTime -> Bool)

Test function: If isCacheStillFresh lastUpdated now returns True the cache is considered still fresh and returns the cached IO action

-> (Maybe (UTCTime, a) -> t a)

action to cache. The stale value and its refresh date are passed so that the action can perform external staleness checks

-> m (t a) 

Cache an IO action, The cache begins uninitialized.

The outer IO is responsible for setting up the cache. Use the inner one to either get the cached value or refresh