@hackage / cached-io

A simple library to cache IO actions

Latest1.4.0.0

Changelog

Revision history for cached-io

1.4.0.0

  • Breaking All cached... functions now require MonadMask for the monad running the refresh action. This was required to support the following bug fix.
  • Fix a subtle bug: if you used a monad with explicit early-exit semantics like MaybeT m or ExceptT e m, and your cached action uses this to exit early, the cache would get stuck in Initializing state and subsequent requests for the cached data would hang forever waiting for initialisation to complete.

1.3.2.0

  • Add Functor instance for Cached.
  • Add cachedIOFromConfig and cachedSTMFromConfig (and a supporting Config type), which let the freshness check inspect the cached value in addition to its timestamp.

1.3.1.0

  • Add cachedSTM versions of all bindings.
  • Correctly transition the internal state to Initializing when filling the cache for the first time.
  • Remove unused transformer dependency

1.3.0.0

  • Breaking Caching functions previously returned m (t a), but it was easy to accidentally use join when m and t were the same monad (eg. IO (IO a)), and not get any caching at all. These functions now use a Cached newtype for t a to make it more difficult to misuse.
Migrating from <=1.2.0.0 to 1.3.0.0
-- Previous versions
f :: IO ()
f = do
  cachedAction <- cachedIO action :: IO (IO a)
  cachedResult <- cachedAction

-- New version
f :: IO ()
f = do
  cachedAction <- cachedIO action :: IO (Cached IO a)
  cachedResult <- runCached cachedAction

1.2.0.0

Thank you glasserc for your work on previous versions, and a special thanks to Arguggi for contributing many of the improvements incorporated into this version.

  • Bellroy is the new maintainer of this package. See https://github.com/glasserc/haskell-cached-io/pull/1.
  • New cachedIO' and cachedIOWith' support generating an action depending on the most recent cached value and its timestamp, if there was one.
  • cachedIO ttl f can now be run in a different monad to f. Similarly for cachedIO', cachedIOWith, cachedIOWith'.
  • Fixes uncaught exceptions leaving the cache in a deadlocked state and other problems.

1.1.0.0 and prior

These versions were published by glasserc.