package ringo

  1. Overview
  2. Docs
Caches (bounded-size key-value stores) and other bounded-size stores

Install

Dune Dependency

Authors

Maintainers

Sources

ringo-v0.6.tar.gz
md5=9e542555814d906bc8da0236e1adf815
sha512=db25e84ed67b6e55d630c372b33e61037bf197407e05ad5bf1b2b5ccf2719fab4437cbd2040d48fd15db590b52f0f1d4598105ca029749702e69e80f2ae15f51

doc/ringo/Ringo/module-type-CACHE_MAP/index.html

Module type Ringo.CACHE_MAPSource

A Mutable structure akin to a hash-table, but with a size bound. Note that, different caches have different policies towards the size bounds: some uphold the bound strictly, some treat the bound as a suggestion. In addition, some caches count their elements somewhat sloppily.

In general, the caches of ringo are intended to be used in settings that do not require strict, by-the-number, extremely-predictable behaviors.

See Ringo (or Functors) for more information.

Sourcetype key

The type of keys on which values in the cache are indexed.

Sourcetype 'a t

The type of caches holding bindings from key to 'a

Sourceval create : int -> 'a t

create n creates a cache with a size-bound of n. Remember that the size-bound is not upheld strictly by all caches.

Sourceval replace : 'a t -> key -> 'a -> unit

replace c k v binds the key k to the value v in the cache c. This may or may not cause another binding to be removed from the cache, depending on the number of bindings already present in the cache c, the size-bound of the cache c, and the policy of the cache c towards its size-bound.

If k is already bound to a value in c, the previous binding disappears and is replaced by the new binding to v.

Note that in caches with a Sloppy accounting policy, the old (removed) binding may still count towards the size bound for some time.

Sourceval fold : (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold f c init folds the function f and value init over the bindings of c.

Note that for caches with a Weak overflow policy, this function may fold over a subset of the bindings of c. See Ringo (or Functors) for more details.

Sourceval fold_v : ('a -> 'b -> 'b) -> 'a t -> 'b -> 'b

fold_v f c init folds the function f and value init over the values held by the bindings of c.

It is less powerful than fold in that it does not grant access to the bindings' keys, but it does fold over all the values bound in c, even when the c has a Weak overflow policy.

Sourceval find_opt : 'a t -> key -> 'a option

find_opt c k is Some v if k is bound to v in c. It is None otherwise.

Note that the in caches with a non-FIFO replacement policy, this may have a side effect on the k-to-v binding. Specifically, in those caches, it might make it less likely to be removed when supernumerary bindings are inserted.

Sourceval remove : 'a t -> key -> unit

remove c k removes the binding from k in c. If k is not bound in c, it does nothing.

Note that in caches with a Sloppy accounting policy, removed bindings can still count towards the size bound for some time.

Sourceval length : 'a t -> int

length c is the number of bindings held by c.

Sourceval capacity : 'a t -> int

capacity c is the number of bindings c can hold: capacity (create n) = n

Sourceval clear : 'a t -> unit

clear c removes all bindings from c.

Sourcemodule H : Hashtbl.HashedType with type t = key
OCaml

Innovation. Community. Security.