Module Prime_cache
Memory cache based on hash tables (prime.unstable).
val create : cache_metric:Prime_cache_metric.t -> int -> ('a, 'b) t
create ~cache_metric n
creates a cache initially scaled for aboutn
entries.- parameter cache_metric
The heuristics for when to retain a cache entry.
val clear : ('a, 'b) t -> unit
clear ct
removes all cached entries fromct
.
val app : ('a, 'b) t -> 'a -> 'b option
app ck k
is the cached mapping ofk
if any.
val find : ('a, 'b) t -> 'a -> 'b
find ct k
returnes the object associated withk
.- raises Not_found
if
k
has no associated object.
val replace : ('a, 'b) t -> float -> 'a -> 'b -> unit
replace ct g k v
replaces the mapping fork
withv
and associates it with a gradeg
.
val remove : ('a, 'b) t -> 'a -> unit
remove ct k
removes any entry cached underk
fromct
. Does nothing ifk
is not in the cache.