package aches
Install
Dune Dependency
Authors
Maintainers
Sources
md5=c9c5400e7ae19100b945279835ff3e5c
sha512=7f37b721e2ca32e5e96fbf8df1bbd72c9060b6826bd95a21ea81af5fdd0c1961d3d7fb41210966aac7c277ec7f91fd32e3e284b583cb02121dc589646642f5c0
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.
SingletonSet(H)
is a set module but it only supports singleton sets: sets with at most one element.