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

Notify when an LRU item is removed #729

Open
davidmartos96 opened this issue May 23, 2023 · 1 comment · May be fixed by #730
Open

Notify when an LRU item is removed #729

davidmartos96 opened this issue May 23, 2023 · 1 comment · May be fixed by #730

Comments

@davidmartos96
Copy link

It would be useful to have some way of knowing when an item is removed from the LRU. If there is some cleanup/disposing logic that need to be done to the stored values, right now there is no way to do it when using a maximumSize, as the entries are removed implicitly.

I propose the following API

final lruMap = LruMap(
    onItemRemoved: (key, value) {
         value.dispose();
    },
)
@davidmartos96 davidmartos96 linked a pull request May 23, 2023 that will close this issue
@AlessandroToschi
Copy link

Nice, I was going to implement the same feature!
Having a callback when an item is evicted from the cache would be really useful!

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 a pull request may close this issue.

2 participants