Skip to content
New issue

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

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

Already on GitHub? # to your account

expirable-lru: Add() replaces existing entry without calling evict callback? #189

Open
shellohunter opened this issue Jan 19, 2025 · 0 comments

Comments

@shellohunter
Copy link

run into a memleak issue with expirable LRU.
here's the scenario:
there's a chance that Get() returns nothing, but Contains() return true, which means the entry has expired, ready for eviction, but not done yet. then, at the same time, another Add() with the same key was called.

  • what expirable LRU does now: the old entry was overwrite silently. which may lead to serious leakage, since the entry may holding some important resource needs to release in the eviction callback.
  • expected behavior: old entry get removed with its eviction callback called.

found a similar issue: #135,
I guess that's why new APIs like ContainsOrAdd were introduced.

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

No branches or pull requests

1 participant