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.
See Finalizer
if you want to run finalizers
automatically when cache entries are evicted
Synopsis
- newtype LruHandle k v = LruHandle (IORef (LruCache k v))
- cached :: (Hashable k, Ord k) => LruHandle k v -> k -> IO v -> IO v
- newLruHandle :: Int -> IO (LruHandle k v)
- newtype StripedLruHandle k v = StripedLruHandle (Vector (LruHandle k v))
- stripedCached :: (Hashable k, Ord k) => StripedLruHandle k v -> k -> IO v -> IO v
- newStripedLruHandle :: Int -> Int -> IO (StripedLruHandle k v)
Documentation
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.
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)) |
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.