lrucaching-0.3.2: LRU cache

Copyright(c) Moritz Kiefer 2016
(c) Jasper Van der Jeugt 2015
LicenseBSD3
Maintainermoritz.kiefer@purelyfunctional.org
Safe HaskellNone
LanguageHaskell2010

Data.LruCache.IO

Description

Convenience module for the common case of caching results of IO actions. See Finalizer if you want to run finalizers automatically when cache entries are evicted

Synopsis

Documentation

newtype LruHandle k v Source #

Store a LRU cache in an 'IORef to be able to conveniently update it.

Constructors

LruHandle (IORef (LruCache k v)) 

cached :: (Hashable k, Ord k) => LruHandle k v -> k -> IO v -> IO v Source #

Return the cached result of the action or, in the case of a cache miss, execute the action and insert it in the cache.

newLruHandle :: Int -> IO (LruHandle k v) Source #

Create a new LRU cache of the given size.

newtype StripedLruHandle k v Source #

Using a stripe of multiple handles can improve the performance in the case of concurrent accesses since several handles can be accessed in parallel.

Constructors

StripedLruHandle (Vector (LruHandle k v)) 

stripedCached :: (Hashable k, Ord k) => StripedLruHandle k v -> k -> IO v -> IO v Source #

Striped version of cached.

newStripedLruHandle :: Int -> Int -> IO (StripedLruHandle k v) Source #

Create a new StripedHandle with the given number of stripes and the given capacity for each stripe.