lrucaching-0.3.3: LRU cache

Copyright (c) Moritz Kiefer 2016(c) Jasper Van der Jeugt 2015 BSD3 moritz.kiefer@purelyfunctional.org None Haskell2010

Data.LruCache.IO.Finalizer

Description

Convenience module for the common case of caching results of IO actions when finalizers have to be run 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, v -> IO ())))

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

Create a new LRU cache of the given size.

Arguments

 :: (Hashable k, Ord k) => LruHandle k v -> k -> IO v -> (v -> IO ()) finalizer -> IO v

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

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))

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

Arguments

 :: (Hashable k, Ord k) => StripedLruHandle k v -> k -> IO v -> (v -> IO ()) finalizer -> IO v

Striped version of cached.