Copyright | (c) Moritz Kiefer, 2016 (c) Jasper Van der Jeugt, 2015 |
---|---|
License | BSD3 |
Maintainer | moritz.kiefer@purelyfunctional.org |
Safe Haskell | None |
Language | Haskell2010 |
Pure API to an LRU cache.
- data LruCache k v
- type Priority = Int64
- empty :: Int -> LruCache k v
- insert :: (Hashable k, Ord k) => k -> v -> LruCache k v -> LruCache k v
- insertView :: (Hashable k, Ord k) => k -> v -> LruCache k v -> (Maybe (k, v), LruCache k v)
- lookup :: (Hashable k, Ord k) => k -> LruCache k v -> Maybe (v, LruCache k v)
Documentation
LRU cache based on hashing. The times of access are stored in a
monotonically increasing Int64
, when that time is at maxbound
the cache is emptied.
insert :: (Hashable k, Ord k) => k -> v -> LruCache k v -> LruCache k v Source #
Insert an element into the LruCache
.