I want to use spring-cache with guava cache, but I find guava cache has been marked deprecated by spring official document.I wonder to know why, they didn't give some explanations.
https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-caching.html#boot-features-caching-provider-guava
Guava provides a very powerful memory based caching mechanism by an interface LoadingCache<K,V>. Values are automatically loaded in the cache and it provides many utility methods useful for caching needs.
Spring Cache uses the parameters of the method as key and the return value as a value in the cache. When the method is called the first time, Spring will check if the value with the given key is in the cache. It will not be the case, and the method itself will be executed.
The @EnableCaching annotation triggers a post-processor that inspects every Spring bean for the presence of caching annotations on public methods. If such an annotation is found, a proxy is automatically created to intercept the method call and handle the caching behavior accordingly.
Spring project decided to endorse a switch to Caffeine cache.
Caffeine supersedes the caching support in the Google Guava library with an actively maintained Java 8+ version in standalone form.
You can find the relevant issue with the decision on Spring's tracker here: https://jira.spring.io/browse/SPR-13797
The relevant commit in spring framework github repo is: https://github.com/spring-projects/spring-framework/commit/2bf9bc312ed1721b5978f88861c29cffc9ea407c
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With