golang-lru
golang-lru copied to clipboard
Enable iteration of key/val pairs in expirable LRU
There is currently no way to iterate over key/val pairs in the cache. Can't combine the outputs of Keys() and Values() since new entries could have been added or old entries expire between the two calls. Only other option would be to call Keys() and Peek(...) every key, but that is not very efficient.
Given that the K/V Entries struct is internal only, I propose adding a Range(...) function that will call a function on each K/V pair in the cache. This way the lock only needs to be acquired once to make a list of current unexpired entries (similar to how the Keys() and Values() functions work), and then the callback is free to make modifications to the cache as it iterates.
Thank you for your submission! We require that all contributors sign our Contributor License Agreement ("CLA") before we can accept the contribution. Read and sign the agreement
Learn more about why HashiCorp requires a CLA and what the CLA includes
Have you signed the CLA already but the status is still pending? Recheck it.
I was looking for something like this. Seems like project is not maintained no reviewrs/approvers ?