BSD-3-Clause licensed by Moritz Kiefer
Maintained by [email protected]
This version can be pinned in stack with:lrucaching-0.3.3@sha256:86879331ad31832faf0df414550ea19ae2172fb5ff516912ea8df8f5f9e6f5fb,2010

Module documentation for 0.3.3

lrucaching

Build Status Hackage

An implementation of lrucaches based on a blogpost by Jasper Van der Jeugt.

This package has no relation to lrucache. I created it because there were bugs in lrucache and the maintainer was not responding to issues.

Usage

The easiest way to use this library is to use Data.LruCache.IO. This wraps the cache in a Data.IORef, a mutable varible in the IO monad.

e.g. To create a 1000-item cache, keyed by Integer, storing String:

import qualified Data.LruCache.IO as LRU

newCache :: IO (LRU.LruHandle Integer String)
newCache = LRU.newLruHandle 1000

cachedLookup cache key = LRU.cached cache key $
    -- insert some something expensive
    return $ show key

main :: IO ()
main = do
    cache <- newCache
    cachedLookup cache 123 >>= putStrLn

Changes

0.3.3

  • Drop support for GHC 7.8
  • Bump QuickCheck upper bound

0.3.2

  • Bump QuickCheck upper bound

0.3.1

  • Allow vector == 0.12.*
  • Do not use hspec-discover. This allows building the tests using cabal new-build.

0.3.0

  • Add Data.LruCache.IO.Finalizer for automatically running finalizer when evicting cache entrvies.
  • Rename newStripedHandle to newStripedLruHandle

0.2.1

  • Fix build with GHC 7.8

0.2.0

  • Don’t clear cache on clock overflow. This means that elements are never evicted without notifying the user via insertView.

0.1.0

Initial release.