Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Documentation
class IsCache m k where Source
newCache :: Maybe Int -> m k v Source
newCache size
. Set a max number of elements the cache will hold.
If the newly inserted element exceeds the size limit, the oldest element is removed from the cache.
newUnlimitedCache :: m k v Source
Alias for newCache Nothing
lookup :: k -> m k v -> Maybe v Source
Lookup an element from the cache
insert :: k -> v -> m k v -> m k v Source
Insert an element to the cache.
If the newly inserted element exceeds the size limit, the oldest element is removed from the cache.
dumpOldest :: m k v -> m k v Source
Remove the oldest key from the cache.
Return the current number of elements.
limit :: m k v -> Maybe Int Source
Return the max number of elements the cache can hold.
setLimit :: Maybe Int -> m k v -> m k v Source
Change the size limit.
dump :: Int -> m k v -> m k v Source
dump n cache
removes n oldest elements from the cache.