expiring-cache-map-0.0.6.1: General purpose simple caching.

Copyright | (c) 2014 Edward L. Blake
License | BSD-style
Maintainer | Edward L. Blake <edwardlblake@gmail.com>
Stability | experimental
Portability | portable
Safe Haskell | Safe
Language | Haskell98

Caching.ExpiringCacheMap.Types

Contents

- Configuration
- Cache encapsulation
- Types
- Types for state function

Description

Types common to Caching.ExpiringCacheMap.OrdECM and Caching.ExpiringCacheMap.HashECM.

Synopsis

- data CacheSettings = CacheWithLRUList {
  - mapsize :: ECMMapSize
  - removalsize :: ECMMapSize
  - compactlistsize :: ECMULength
  }
- data ECM a b s m k v
- data CacheState s m k v
- type TimeUnits = Int
- type ECMMapSize = Int
- type ECMULength = Int
- type ECMIncr = Word32
- type ECMNewState a b s m k v = CacheState s m k v -> a (b (CacheState s m k v))
- type ECMEnterState a b s m k v = b (CacheState s m k v) -> (CacheState s m k v -> a (CacheState s m k v, v)) -> a v
- type ECMReadState a b s m k v = b (CacheState s m k v) -> a (CacheState s m k v)

# Configuration

data CacheSettings #

Constructors

CacheWithLRUList | 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.
Fields mapsize :: ECMMapSize removalsize :: ECMMapSize compactlistsize :: ECMULength

# Cache encapsulation

data ECM a b s m k v #

The type that encapsulates a cache map.

data CacheState s m k v #

The cache state.

# Types

type TimeUnits = Int #

Integer involved in the time units used to determine when an item expires. The time units used can be any arbitrary integer time representation, such as seconds or milliseconds for examples. They can also be deterministic time steps in a sequencing monad.

type ECMMapSize = Int #

Integer involved in the size of a key-value map.

type ECMULength = Int #

Integer involved in the length of the usage history list.

type ECMIncr = Word32 #

Unsigned integer (`Word32`) involved in the cache state incrementing accumulator.

# Types for state function

type ECMNewState a b s m k v = CacheState s m k v -> a (b (CacheState s m k v)) #

type ECMEnterState a b s m k v = b (CacheState s m k v) -> (CacheState s m k v -> a (CacheState s m k v, v)) -> a v #

type ECMReadState a b s m k v = b (CacheState s m k v) -> a (CacheState s m k v) #