Legend:
Library
Module
Module type
Parameter
Class
Class type
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.
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 binding is erased but may still count towards the size bound for some time. In other words: apart for size bound consideration, the following sequences of operations are indistinguishable: replace c k v; replace c k ureplace c k v; remove c k; replace c k u
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.
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.