File: Types.hs

package info (click to toggle)
haskell-expiring-cache-map 0.0.6.1-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 232 kB
  • sloc: haskell: 2,209; makefile: 5
file content (51 lines) | stat: -rw-r--r-- 1,709 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
{-# LANGUAGE OverloadedStrings #-}
-- |
-- Module : Caching.ExpiringCacheMap.Types
-- Copyright: (c) 2014 Edward L. Blake
-- License: BSD-style
-- Maintainer: Edward L. Blake <edwardlblake@gmail.com>
-- Stability: experimental
-- Portability: portable
--
-- Types common to "Caching.ExpiringCacheMap.OrdECM" and "Caching.ExpiringCacheMap.HashECM".
-- 

module Caching.ExpiringCacheMap.Types (
    -- * Configuration
    CacheSettings(..),
    -- * Cache encapsulation
    ECM,
    CacheState,
    -- * Types
    TimeUnits,
    ECMMapSize,
    ECMULength,
    ECMIncr,
    -- * Types for state function
    ECMNewState,
    ECMEnterState,
    ECMReadState,
) where

import Caching.ExpiringCacheMap.Utils.Types
import Caching.ExpiringCacheMap.Internal.Types

data CacheSettings =
  -- | A cache that maintains a key access history list to perform removals
  -- of /least recently used/ entries. Once the key-value map reaches 
  -- 'removalsize' keys, then a list of keys to keep in the map is determined 
  -- which is no larger than 'mapsize' size. Entries are removed only on 
  -- insertion of a new entry in the key-value map.
  -- 
  -- Key access history entries are prepended to the head of the LRU list, 
  -- if an existing entry for the key appears close to the head of the list
  -- it is moved to the head of the list, instead of growing the list. When the 
  -- LRU list reaches 'compactlistsize' items, it is compacted by removing 
  -- duplicate keys, by keeping only the most recent accumulator value for 
  -- that key.
  --
  CacheWithLRUList {
    mapsize :: ECMMapSize,
    removalsize :: ECMMapSize,
    compactlistsize :: ECMULength
  }