package aches

  1. Overview
  2. Docs

Rache

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.

Caches

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.

Cache policies

module type REPLACEMENT

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

Cache instantiating

module Transfer (R : REPLACEMENT) (H : Hashtbl.HashedType) : TRANSFER with type key = H.t

Transfer(R)(H) is a TRANSFER indexed by H and govern by the replacement policy R.

module Borrow (R : REPLACEMENT) (H : Hashtbl.HashedType) : BORROW with type key = H.t

Borrow(R)(H) is a BORROW indexed by H and govern by the replacement policy R.

EmptyTransferMap(H) is a transfer-map module but it only supports the empty map: a map with zero elements.

SingletonTransferMap(H) is a transfer-map module but it only supports singleton maps: maps with at most one element.

module EmptyBorrowMap (H : Hashtbl.HashedType) : BORROW with type key = H.t

EmptyBorrowMap(H) is a borrow-map module but it only supports the empty map: a map with zero elements.

SingletonBorrowMap(H) is a borrow-map module but it only supports singleton maps: maps with at most one element.

OCaml

Innovation. Community. Security.