Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why did Spring framework deprecate the use of Guava cache?

Tags:

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

like image 301
mengying.ye Avatar asked May 25 '17 07:05

mengying.ye


People also ask

Is guava in memory cache?

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.

How does Spring cache work?

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.

Does spring cache beans?

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.


1 Answers

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

like image 106
Giorgos Gaganis Avatar answered Sep 19 '22 09:09

Giorgos Gaganis