Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable iteration of key/val pairs in expirable LRU #178

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bhperry
Copy link

@bhperry bhperry commented May 28, 2024

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.

Copy link

hashicorp-cla-app bot commented May 28, 2024

CLA assistant check
All committers have signed the CLA.

Copy link

CLA assistant check

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.

@rajatkb
Copy link

rajatkb commented Dec 14, 2024

I was looking for something like this. Seems like project is not maintained no reviewrs/approvers ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants