-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Please see the README on Github at -- https://github.com/ChrisCoffey/exp-cache#readme @package exp-cache @version 0.1.0.2 module Data.Cache.Eviction.FIFO -- | A First in First Out eviction strategy. Items are evicted based on -- order added, regardless of usage patterns. data FIFO k newFIFO :: FIFO k instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.FIFO.FIFO k) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.Cache.Eviction.FIFO.FIFO k) instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.FIFO.FIFO module Data.Cache.Eviction.LFU -- | Evict the least frequently used element from the cache. This means as -- an element is accessed, its "score" increases and the element is more -- likely to survive eviction once the cache fills up. data LFU k newLFU :: LFU k newtype LFUContentsOnlyEq k LFUContentsOnlyEq :: (LFU k) -> LFUContentsOnlyEq k instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.LFU.LFUContentsOnlyEq k) instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.LFU.LFU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LFU.LFU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LFU.LFUContentsOnlyEq k) instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.LFU.LFU module Data.Cache.Eviction.LRU -- | This is a naive and terribly slow version of an LRU cache data SeqLRU k newSeqLRU :: SeqLRU k -- | An optimized version of an LRU cache. The least recently used element -- in the cache is evicted once the cache fills up. data LRU k newLRU :: LRU k newtype LRUContentsOnlyEq k LRUContentsOnlyEq :: (LRU k) -> LRUContentsOnlyEq k instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.LRU.LRUContentsOnlyEq k) instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.LRU.LRU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LRU.LRU k) instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.LRU.SeqLRU k) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.Cache.Eviction.LRU.SeqLRU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LRU.LRUContentsOnlyEq k) instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.LRU.LRU instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.LRU.SeqLRU module Data.Cache.Eviction.MRU -- | A Most Recently Used cache. This evicts the most recently accessed -- item from the cache data MRU k newMRU :: MRU k newtype MRUContentsOnlyEq k MRUContentsOnlyEq :: (MRU k) -> MRUContentsOnlyEq k instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.MRU.MRUContentsOnlyEq k) instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.MRU.MRU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.MRU.MRU k) instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.MRU.MRUContentsOnlyEq k) instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.MRU.MRU module Data.Cache.Eviction.RR -- | Random Replacement cache. The seed is fixed to an StdGen since -- its both easily accessible & good enough for this purpose. Random -- replacement means exactly what it sounds like: when the cache fills up -- a random element is selected and evicted. data RR k -- | Generate a new Random Replacement cache using the provided seed & -- size. newRR :: StdGen -> Int -> RR k rrSizeDebug :: RR k -> Int instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.RR.RR k) instance GHC.Show.Show k => GHC.Show.Show (Data.Cache.Eviction.RR.StupidBiMap k) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.Cache.Eviction.RR.StupidBiMap k) instance GHC.Classes.Eq k => GHC.Classes.Eq (Data.Cache.Eviction.RR.RR k) instance Data.Cache.Eviction.EvictionStrategy Data.Cache.Eviction.RR.RR module Data.Cache -- | A Cache is a bounded collection of data that supports fast random -- access. When the cach is full, the associated EvictionStrategy -- is used to discard an item from the cache. Library users should use -- readThrough to read and replace items in the cache. data Cache k v s -- | Create a new cache of the specified size using the provided -- EvictionStrategy newCache :: (Hashable k, NFData v, EvictionStrategy s, Eq k, Ord k) => Natural -> s k -> Cache k v (s k) -- | Performs a read-through operation on a given cache. readThrough :: (Hashable k, NFData v, EvictionStrategy s, Eq k, Ord k, Monad m) => Cache k v (s k) -> k -> (k -> m v) -> m (v, Cache k v (s k)) class EvictionStrategy s recordLookup :: (EvictionStrategy s, Eq k, Hashable k, Ord k) => k -> s k -> s k evict :: (EvictionStrategy s, Eq k, Hashable k, Ord k) => s k -> (s k, Maybe k) -- | This is a naive and terribly slow version of an LRU cache data SeqLRU k newSeqLRU :: SeqLRU k -- | An optimized version of an LRU cache. The least recently used element -- in the cache is evicted once the cache fills up. data LRU k newLRU :: LRU k -- | A Most Recently Used cache. This evicts the most recently accessed -- item from the cache data MRU k newMRU :: MRU k -- | Random Replacement cache. The seed is fixed to an StdGen since -- its both easily accessible & good enough for this purpose. Random -- replacement means exactly what it sounds like: when the cache fills up -- a random element is selected and evicted. data RR k -- | Generate a new Random Replacement cache using the provided seed & -- size. newRR :: StdGen -> Int -> RR k -- | Evict the least frequently used element from the cache. This means as -- an element is accessed, its "score" increases and the element is more -- likely to survive eviction once the cache fills up. data LFU k newLFU :: LFU k -- | A First in First Out eviction strategy. Items are evicted based on -- order added, regardless of usage patterns. data FIFO k newFIFO :: FIFO k