Copyright | (c) Moritz Kiefer 2016 (c) Jasper Van der Jeugt 2015 |
---|---|
License | BSD3 |
Maintainer | moritz.kiefer@purelyfunctional.org |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Convenience module for the common case of caching results of IO actions when finalizers have to be run when cache entries are evicted.
Synopsis
- newtype LruHandle k v = LruHandle (IORef (LruCache k (v, v -> IO ())))
- newLruHandle :: Int -> IO (LruHandle k v)
- cached :: (Hashable k, Ord k) => LruHandle k v -> k -> IO v -> (v -> IO ()) -> IO v
- newtype StripedLruHandle k v = StripedLruHandle (Vector (LruHandle k v))
- newStripedLruHandle :: Int -> Int -> IO (StripedLruHandle k v)
- stripedCached :: (Hashable k, Ord k) => StripedLruHandle k v -> k -> IO v -> (v -> IO ()) -> IO v
Documentation
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.
StripedLruHandle (Vector (LruHandle k v)) |
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.
Striped version of cached
.