Library
Module
Module type
Parameter
Class
Class type
Rache is a library for resource caches.
More specifically, Rache provides modules implementing caches for resources. These caches are parametrised by cache-policies: replacement policy and maximum size. The caches also provide a clean-up mechanism to deal with resource tear-down.
module type TRANSFER = sig ... end
TRANSFER
are caches in which resources can be put and from which resources can be taken. More precisely, caches where the ownership of the resources (the responsibility to clean them up) can be transferred into and out of the cache.
module type BORROW = sig ... end
BORROW
are caches in which resources can be borrowed but never transferred. In other words, the cache retains ownership of all resources.
All caches of Rache have either the TRANSFER
interface (for caches with transfer of ownership) or the BORROW
interface (for caches with borrowing of resources). Their behaviour can be tweaked by the parameters below.
REPLACEMENT
is for defining the replacement policy of a cache. LRU
is for "Least Recently Used", meaning that when a supernumerary item is inserted in the cache, the least recently used item is removed to make room. FIFO
is for "First-In, First-Out" meaning that when a supernumerary item is inserted in the cache, the oldest inserted element is removed to make room.
module LRU : REPLACEMENT
module FIFO : REPLACEMENT
Transfer(R)(H)
is a TRANSFER
indexed by H
and govern by the replacement policy R
.
Borrow(R)(H)
is a BORROW
indexed by H
and govern by the replacement policy R
.
Empty*
and Singleton*
are specialised 0-size and 1-size variants of caches.
Note that these caches are not govern by any replacement policy. This is because they hold so few elements (0 or 1) that all the policy are equivalent.
Note that the create
function ignores its argument: the caches size-limits are hard-set by the functor.
module EmptyTransferMap
(H : Stdlib.Hashtbl.HashedType) :
TRANSFER with type key = H.t
A Mutable structure akin to a hash-table, but with a size bound. When an element is added that would cause the size to overflow the bound, a different element is removed.
module SingletonTransferMap
(H : Stdlib.Hashtbl.HashedType) :
TRANSFER with type key = H.t
A Mutable structure akin to a hash-table, but with a size bound. When an element is added that would cause the size to overflow the bound, a different element is removed.
module EmptyBorrowMap
(H : Stdlib.Hashtbl.HashedType) :
BORROW with type key = H.t
A BORROW
is similar to a TRANSFER
except that:
module SingletonBorrowMap
(H : Stdlib.Hashtbl.HashedType) :
BORROW with type key = H.t
A BORROW
is similar to a TRANSFER
except that: