-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
CaffeineCache does not support LoadingCache consistently #25173
Comments
Yes. The cache abstraction is meant to be used as follows: @Cacheable
public MyObject computeSomethingExpensive(String key) { ... } Using |
Hi @snicoll , I agree with you that the use of a loading cache with @cacheble is incompatible (and I would add "strange"). |
I overlooked your report, sorry about that. I find it strange that we have a case for supporting the loading cache there so let's reopen to at least check. You haven't really shared why you're reporting this. What made you create this issue in the first place? |
I have an application where we are using the Spring Checking the source code of |
Thanks for the feedback and that clarifies the issue quite a bit. If we can consistently call the |
When CaffeineCache is created with a LoadingCache, the LoadingCache is used with the method `public ValueWrapper get(Object key)` but not with method `public <T> T get(Object key, @nullable Class<T> type)`. Using LoadingCache is incompatible with @Cacheable pattern but consistently call the LoadingCache in both methods is better than now. Removing the usage is a backward-incompatible change. Closes spring-projectsgh-25173
Hi all
CaffeineCache implementation override method
public ValueWrapper get(Object key)
and there is a specific check when a LoadingCache is provided.In this case, the CacheLoader of the LoadingCache is used to retrieve the data (if not already present int the cache).
I don't see the same behavior for the method
public <T> T get(Object key, @Nullable Class<T> type)
.In this case, the CacheLoader of the LoadingCache is never used. Using only this method... the cache will be always empty.
Is there any reason for this different behavior?
Thanks
Stefano
The text was updated successfully, but these errors were encountered: