chickadee » lru-cache » lru-cache-fold

lru-cache-fold cache kons knilprocedure

Iterate over the items in the cache in order from MRU to LRU. kons is called with three arguments: k, the item's key; v, the item's value; and s, the current state. The initial state is set to knil, and the return value from the call to kons is passed as the next state value to kons.

For example, to build a list of (key . value) pairs in cache from LRU to MRU, execute:

(lru-cache-fold cache (lambda (k v s) (cons (cons k v) s)) '())