-
Notifications
You must be signed in to change notification settings - Fork 892
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
Weak cache optimization #5344
Weak cache optimization #5344
Conversation
if (value != null) { | ||
return value; | ||
} | ||
// Best we can do, we don't expect high contention with this implementation. Note, this |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof yeah stopped being true when stopped using caffeine
resetLookupKey(lookupKey); | ||
} | ||
return previous == null | ||
? target.computeIfAbsent(new WeakKey<>(key, this), ignored -> mappingFunction.apply(key)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought this was impossible due to needing to pass the weak key to mapping function but the solution of using a capturing lambda was so simple!
thx @danielqsj! can you open an issue for this? |
No description provided.