Library
Module
Module type
Parameter
Class
Class type
type key = K.t
type 'a monad = 'a M.t
The type of cache from keys of type key
to values of type 'a
. Cache access must be protected by mutex in a multithread environment. This is not needed when using Async or Lwt. In these cases, the computation function passed to get
should return a Deferred.t
of Lwt.t
.
init size
creates a new cache, size
being the maximum number of entries in the cache.
get cache key compute
returns the value associated to key
in the cache and set this key as the most recently used. If no value is associated to this key, remove the least recently used (key,value) pair from the cache (if the cache is full) and add (key, compute key
), setting this pair as the most recently used.