karlseguin / ccache

A golang LRU Cache for high concurrency
MIT License
1.27k stars 118 forks source link

How to traverse all items in the cache? #54

Closed HDT3213 closed 3 years ago

karlseguin commented 3 years ago

Cannot. But there's a DeletePrefix that could be used as a base for implementing this. I can look at it as it should be quite easy. Mind explaining the use-case a little more?

HDT3213 commented 3 years ago

I want to search for elements that meet certain conditions in the cached collection

karlseguin commented 3 years ago

Does this solve your requirement? https://github.com/karlseguin/ccache/commit/bcaca36409e144647174b5a87d235eb5ba0a3780

HDT3213 commented 3 years ago

I think if I could break the for each in advance would be better. How about this: pull#55

karlseguin commented 3 years ago

I like your approach.

https://github.com/karlseguin/ccache/commit/ae1872d7009cf48f9441f62753360265b4016da7

Makes the name consistent with the DeleteFunc function, applies the same logic to the layered cache, and adds test.

HDT3213 commented 3 years ago

I think it satisfies my needs perfectly. Thank you very much! I'm looking forward to your next release.