Otherwise, it generates r using mk, then inserts the binding k-to-r in c, then calls f r.
Note that inserting the binding in c may cause another binding to be removed and its associated resource to be cleaned-up.
It is unsafe to make use of c during the evaluation of f.
It is unsafe to clean-up r.
Note that the in caches with a non-FIFO replacement policy, this may have a side effect on the k-to-r binding. Specifically, in those caches, it might make it less likely to be removed when supernumerary bindings are inserted.
borrow c k f calls f with r if k is bound to r in c. This does not remove the resource from the cache: the cache is still responsible for cleaning-up the resource.
It is unsafe to use the cache from within the function f.
It is unsafe to clean-up r.
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.
fold_oldest_first is like fold but in reversed order: the elements that would be the first to be removed are traversed first. In a FIFO cache, it is oldest-first traversal.
The same limitations and warning applies as for fold.
Removing elements from the cache
The removal functions (remove, clear, and filter) remove the specified elements from the cache. In all cases, the resources are cleaned-up by the cache.