lrucaching: LRU cache

[ bsd3, library, unknown ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.3.1, 0.3.2, 0.3.3, 0.3.4
Change log CHANGELOG.md
Dependencies base (>=4.8 && <5), base-compat (>=0.9 && <0.14), deepseq (>=1.4 && <1.6), hashable (>=1.2 && <1.5), psqueues (>=0.2 && <0.3), vector (>=0.11 && <0.14) [details]
Tested with ghc ==7.10.3, ghc ==8.0.2, ghc ==8.2.2, ghc ==8.4.3, ghc ==8.6.5, ghc ==8.8.1
License BSD-3-Clause
Copyright 2016
Author Moritz Kiefer
Maintainer moritz.kiefer@purelyfunctional.org
Category Unknown
Home page https://github.com/cocreature/lrucaching#readme
Source repo head: git clone https://github.com/cocreature/lrucaching
Uploaded by cocreature at 2024-01-10T17:32:34Z
Distributions LTSHaskell:0.3.4
Reverse Dependencies 4 direct, 0 indirect [details]
Downloads 6829 total (32 in the last 30 days)
Rating 1.75 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-01-10 [all 1 reports]

Readme for lrucaching-0.3.4

[back to package description]

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