lrucaching: LRU cache

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.


Please see

[Skip to ReadMe]


Versions0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.3
Dependenciesbase (>=4.8 && <5), base-compat (==0.9.*), deepseq (==1.4.*), hashable (==1.2.*), psqueues (==0.2.*), vector (>=0.11 && <0.13) [details]
AuthorMoritz Kiefer
Home page
Source repositoryhead: git clone
UploadedFri Jan 12 13:18:55 UTC 2018 by cocreature




Maintainers' corner

For package maintainers and hackage trustees

Readme for lrucaching-0.3.3

[back to package description]


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.


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