lrucaching-0.3.1: LRU cache

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

Data.LruCache

Description

Pure API to an LRU cache.

Synopsis

Documentation

data LruCache k v Source #

LRU cache based on hashing.

Instances

Functor (LruCache k) Source # 

Methods

fmap :: (a -> b) -> LruCache k a -> LruCache k b #

(<$) :: a -> LruCache k b -> LruCache k a #

Foldable (LruCache k) Source # 

Methods

fold :: Monoid m => LruCache k m -> m #

foldMap :: Monoid m => (a -> m) -> LruCache k a -> m #

foldr :: (a -> b -> b) -> b -> LruCache k a -> b #

foldr' :: (a -> b -> b) -> b -> LruCache k a -> b #

foldl :: (b -> a -> b) -> b -> LruCache k a -> b #

foldl' :: (b -> a -> b) -> b -> LruCache k a -> b #

foldr1 :: (a -> a -> a) -> LruCache k a -> a #

foldl1 :: (a -> a -> a) -> LruCache k a -> a #

toList :: LruCache k a -> [a] #

null :: LruCache k a -> Bool #

length :: LruCache k a -> Int #

elem :: Eq a => a -> LruCache k a -> Bool #

maximum :: Ord a => LruCache k a -> a #

minimum :: Ord a => LruCache k a -> a #

sum :: Num a => LruCache k a -> a #

product :: Num a => LruCache k a -> a #

Traversable (LruCache k) Source # 

Methods

traverse :: Applicative f => (a -> f b) -> LruCache k a -> f (LruCache k b) #

sequenceA :: Applicative f => LruCache k (f a) -> f (LruCache k a) #

mapM :: Monad m => (a -> m b) -> LruCache k a -> m (LruCache k b) #

sequence :: Monad m => LruCache k (m a) -> m (LruCache k a) #

(Ord k, Hashable k, Eq v) => Eq (LruCache k v) Source # 

Methods

(==) :: LruCache k v -> LruCache k v -> Bool #

(/=) :: LruCache k v -> LruCache k v -> Bool #

(Show v, Show k) => Show (LruCache k v) Source # 

Methods

showsPrec :: Int -> LruCache k v -> ShowS #

show :: LruCache k v -> String #

showList :: [LruCache k v] -> ShowS #

(NFData k, NFData v) => NFData (LruCache k v) Source # 

Methods

rnf :: LruCache k v -> () #

type Priority = Int64 Source #

Logical time at which an element was last accessed.

empty :: Int -> LruCache k v Source #

Create an empty LruCache of the given size.

insert :: (Hashable k, Ord k) => k -> v -> LruCache k v -> LruCache k v Source #

Insert an element into the LruCache.

insertView :: (Hashable k, Ord k) => k -> v -> LruCache k v -> (Maybe (k, v), LruCache k v) Source #

Insert an element into the LruCache returning the evicted element if any.

When the logical clock reaches its maximum value and all values are evicted Nothing is returned.

lookup :: (Hashable k, Ord k) => k -> LruCache k v -> Maybe (v, LruCache k v) Source #

Lookup an element in an LruCache and mark it as the least recently accessed.