exp-cache 0.1.0.1 → 0.1.0.2
raw patch · 3 files changed
+19/−4 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Data.Cache.Eviction.LFU: instance (GHC.Classes.Ord k, Data.Hashable.Class.Hashable k) => GHC.Classes.Eq (Data.Cache.Eviction.LFU.LFU k)
- Data.Cache.Eviction.LRU: instance (GHC.Classes.Ord k, Data.Hashable.Class.Hashable k) => GHC.Classes.Eq (Data.Cache.Eviction.LRU.LRU k)
- Data.Cache.Eviction.MRU: instance (GHC.Classes.Ord k, Data.Hashable.Class.Hashable k) => GHC.Classes.Eq (Data.Cache.Eviction.MRU.MRU k)
+ Data.Cache.Eviction.LFU: instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LFU.LFU k)
+ Data.Cache.Eviction.LRU: instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.LRU.LRU k)
+ Data.Cache.Eviction.MRU: instance (Data.Hashable.Class.Hashable k, GHC.Classes.Ord k) => GHC.Classes.Eq (Data.Cache.Eviction.MRU.MRU k)
Files
- README.md +16/−2
- exp-cache.cabal +1/−1
- src/Data/Cache/Eviction/FIFO.hs +2/−1
README.md view
@@ -1,3 +1,17 @@-# lru-cache+# Expressive Caching -[](https://travis-ci.org/ChrisCoffey/Cache-Eviction-Strategies)+[](https://travis-ci.org/ChrisCoffey/exp-cache)++Calling this library "Expressive Caching" perhaps implies <Fill this in>. So why does this library exist? Basically, I wanted to explore how different caching strategies behave under simliar workloads. While its generally true that given enough time and effort you can think through how a particular workload will behave, its usually simpler to just try a few represenative samples. This library provides the ability to swap out the expiration strategy for a given cache with a single line of code.+Traditionally you'll find an LRU or MRU cache library with all of the expiration logic inlined with the retrival logic. Admittedly, this is more memory efficient, but since caches are all about trading memory for CPU cycles anyways, I decided to separate the expiration logic from the retrival logic. This accomplished my initial goal of making it easy to play the same workload across different strategies, but it also had the hidden benefit of making it easier to implement each eviction strategy.++The library currently supports:+- FIFO : a queue+- LRU : Least Recently Used *TODO add a link+- MRU : Most Recently Used *TODO add a link+- LFU : Least Frequently Used *TODO add a link+- RR : Random Replacement *TODO add a link++Its trivial to define alternative eviction strategies using the `EvictionStrategy` class.++
exp-cache.cabal view
@@ -1,5 +1,5 @@ name: exp-cache-version: 0.1.0.1+version: 0.1.0.2 description: Please see the README on Github at <https://github.com/ChrisCoffey/exp-cache#readme> homepage: https://github.com/ChrisCoffey/exp-cache#readme bug-reports: https://github.com/ChrisCoffey/exp-cache/issues
src/Data/Cache/Eviction/FIFO.hs view
@@ -3,6 +3,7 @@ newFIFO ) where +import Prelude hiding (filter) import Data.Cache.Eviction import Data.Sequence @@ -20,4 +21,4 @@ evict (FIFO keys) = case viewr keys of EmptyR -> (FIFO keys, Nothing)- rest :> last -> (FIFO rest, Just last)+ rest :> last -> (FIFO $ filter (/= last) rest, Just last)