Library
Module
Module type
Parameter
Class
Class type
Vache is a library for in-memory value caches.
More specifically, Vache provides modules implementing caches for values. These caches are parametrised by cache-policies: maximum size, retention, etc.
Note that Vache should not be used to cache resources which may need any form of clean-up (e.g., file-descriptors or network connections). Vache should only be used for values which can be entirely managed by the garbage-collector. If you need resource caches, check-out Rache.
module type MAP = sig ... end
A Mutable structure akin to a hash-table, but with a size bound. Note that, different caches have different policies towards the size bounds: some uphold the bound strictly, some treat the bound as a suggestion. In addition, some caches count their elements somewhat sloppily.
module type SET = sig ... end
A Mutable structure akin to a set, but with a size bound. Note that, different caches have different policies towards the size bounds: some uphold the bound strictly, some treat the bound as a suggestion. In addition, some caches count their elements somewhat sloppily.
All caches of Vache have either the MAP
interface (for key-value stores) or the SET
interface (for value stores). Their behavior can be tweaked by the parameters below.
REPLACEMENT_AND_ACCOUNTING
is for defining the replacement policy and the accounting policy of a cache. Because of implementation details which are not relevant to go into details here, these two policies are governed by a single, joined parameter.
module LRU_Precise : REPLACEMENT_AND_ACCOUNTING
module LRU_Sloppy : REPLACEMENT_AND_ACCOUNTING
module FIFO_Precise : REPLACEMENT_AND_ACCOUNTING
module FIFO_Sloppy : REPLACEMENT_AND_ACCOUNTING
OVERFLOW
is for defining the overflow policy of a cache. Strong
means that the cache never holds more element than is specified when calling create
. Weak
means that the cache may hold more elements than specified when calling create
but that supernumerary elements may be collected by the Garbage Collector.
module Strong : OVERFLOW
module Weak : OVERFLOW
module Map
(RA : REPLACEMENT_AND_ACCOUNTING)
(O : OVERFLOW)
(H : Hashtbl.HashedType) :
MAP with type key = H.t
Map(RA)(O)(H) is a [MAP] indexed by [H] and governed by [RA] and [O].
EmptyMap(H)
is a map module but it only supports the empty map: a map with zero elements.
module SingletonMap (H : Hashtbl.HashedType) : MAP with type key = H.t
SingletonMap(H)
is a map module but it only supports singleton maps: maps with at most one element.
module Set
(RA : REPLACEMENT_AND_ACCOUNTING)
(O : OVERFLOW)
(H : Hashtbl.HashedType) :
SET with type elt = H.t
Set(RA)(O)(H) is a [SET] indexed by [H] and governed by [RA] and [O].
EmptySet(H)
is a set module but it only supports the empty set: a set with zero elements.
module SingletonSet (H : Hashtbl.HashedType) : SET with type elt = H.t
SingletonSey(H)
is a set module but it only supports singleton sets: sets with at most one element.