Skip to content

Conversation

@xonatius
Copy link
Contributor

@xonatius xonatius commented Oct 16, 2025

Thanks for this crate, it's awesome! One thing that was missing for me is ability to remove the entry only if its value matches what I expect. I've added Cache::remove_if which makes it possible to achieve that.

I've added it only for the sync version of the Cache, as with unsync version you can just do peek + remove, but let me know if I should add it to unsync too for consistency.

@arthurprs
Copy link
Owner

This is great, thank you.

Can you also add it to unsink? While it can be reproduced with peek+remove there, avoiding the second hashmap lookup is still relevant.

@xonatius
Copy link
Contributor Author

Can you also add it to unsink? While it can be reproduced with peek+remove there, avoiding the second hashmap lookup is still relevant.

Makes sense, done!

This method removes the entry from cache for a given key only if a
provided predicate returns true for the entry's value.
@arthurprs arthurprs merged commit a688eb2 into arthurprs:master Oct 18, 2025
11 checks passed
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