| Copyright | (c) 2015 Călin Ardelean |
|---|---|
| License | MIT |
| Maintainer | Călin Ardelean <calinucs@gmail.com> |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
| Extensions |
|
Database.Muesli.Cache
Description
LRU cache implementation using the psqueues package.
This module should be imported qualified.
- data DynValue = DynValue {}
- data LRUCache = LRUCache {
- minCapacity :: !Int
- maxCapacity :: !Int
- maxAge :: !NominalDiffTime
- size :: !Int
- queue :: !(IntPSQ UTCTime DynValue)
- empty :: Int -> Int -> NominalDiffTime -> LRUCache
- insert :: Typeable a => UTCTime -> Int -> a -> Int -> LRUCache -> LRUCache
- lookup :: Typeable a => UTCTime -> Int -> LRUCache -> Maybe (a, Int, LRUCache)
- delete :: Int -> LRUCache -> LRUCache
- trim :: UTCTime -> LRUCache -> LRUCache
Documentation
Holds a Dynamic and the size of the corresponding serialized data.
A LRU cache that uses a lower capacity in periods of inactivity. This behaviour would be useful for things like long lived Android services.
Constructors
| LRUCache | |
Fields
| |
Arguments
| :: Int | Minimum capacity (in bytes) |
| -> Int | Maximum capacity (in bytes) |
| -> NominalDiffTime | Maximum age (in seconds) |
| -> LRUCache |
Creates an empty cache.
Arguments
| :: Typeable a | |
| => UTCTime | Current time |
| -> Int | Key |
| -> a | Value |
| -> Int | Size (in bytes) |
| -> LRUCache | |
| -> LRUCache |
Adds a new item to the cache, and trims.
Looks up an item into the cache.
If found, it updates the access time for the item, and then trims.