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

ConcurrentLfu.Clear() polluted by removed items #401

Merged
merged 2 commits into from
Oct 2, 2023

Conversation

bitfaster
Copy link
Owner

@bitfaster bitfaster commented Oct 2, 2023

Calling Clear() with BackgroundThreadScheduler can result in a situation where window/probation/protected contains an item that was already removed. Since the clear logic trims n items, where n == cache.Count, the already removed items pollute the list of candidates resulting in non-removed items remaining in the cache.

@bitfaster bitfaster linked an issue Oct 2, 2023 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Oct 2, 2023

Coverage Status

coverage: 97.121% (-0.06%) from 97.185% when pulling 8a27bbf on users/alexpeck/lfuclear into 1e7741f on main.

@bitfaster bitfaster marked this pull request as ready for review October 2, 2023 18:35
@bitfaster bitfaster merged commit 822e160 into main Oct 2, 2023
13 checks passed
@bitfaster bitfaster deleted the users/alexpeck/lfuclear branch October 2, 2023 18:38
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.

Clearing LFU cache doesn't actually clear it
2 participants