persistent-map-0.0.0: Data/CacheStructure/LRU.hs
-----------------------------------------------------------------------------
-- |
-- Module : Data.Policy.LRU
-- Copyright : Peter Robinson 2009
-- License : LGPL
--
-- Maintainer : Peter Robinson <thaldyron@gmail.com>
-- Stability : experimental
-- Portability : non-portable (requires STM)
--
-- Provides a least recently used caching policy.
-- Note: This module is simply a wrapper around the LRU-package.
-----------------------------------------------------------------------------
module Data.CacheStructure.LRU( L.LRU )
where
import Control.Exception
import Data.CacheStructure
import qualified Data.LRU as L
instance Ord a => CacheStructure L.LRU a where
hit = L.hit
pop l = case L.last l of
Nothing -> throw $ CacheException "Cache structure is empty!"
Just a -> (L.pop l,a)
last l = case L.last l of
Nothing -> throw $ CacheException "Cache structure is empty!"
Just a -> a
empty = L.empty
null = L.null
toList = L.toList
delete = L.delete
member = L.member
size = L.size