package aches
Install
Dune Dependency
Authors
Maintainers
Sources
md5=c4bfe8506ee67b82bf5a4f5a989711d3
sha512=4c06df137173a605f14d1bf06193e591b02bd61518669f2d77513e7cd9ad7b660d5ea913cbb079eef8ac17246a71422827594dfe5ffaec032284e0de7e660305
doc/aches.vache/Vache/index.html
Module Vache
Source
Vache
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.
Preamble
Caches
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.
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.
Cache policies
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.
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.
Cache instantiating
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.
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.
SingletonSey(H)
is a set module but it only supports singleton sets: sets with at most one element.