package hc

  1. Overview
  2. Docs

The type of custom cache modules.

type key

The type of keys.

type !'a t

The type of caches with 'a values.

val create : int -> 'a t

create n creates a new, empty cache, with initial size n. For best results, n should be on the order of the expected number of elements that will be in the cache. The cache must grow as needed, so n is just an initial guess.

val clear : 'a t -> unit

Empty a cache.

val add : 'a t -> key -> 'a -> unit

add cache key v adds a binding of key to v in cache cache.

val find : 'a t -> key -> 'a

find cache v returns the current binding of v in cache, or must raise Not_found if v is not in cache.

val length : 'a t -> int

length cache returns the number of bindings in cache.

val stats : 'a t -> Hashtbl.statistics

stats cache return statistics about the cache cache.

OCaml

Innovation. Community. Security.