Default Cache Manager Using Spring Boot Using @EnableCaching

I used caching in my SpringBootApplication as shown below.

@SpringBootApplication
@EnableCaching
public class SampleApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(SampleApplication.class);
    }

    public static void main(String[] args) {
        SpringApplication.run(SampleApplication.class, args);
    }

This works absolutely fine.

But to implement caching, one required CacheManager / Cacheprovider must be installed. Without identifying any cacheManager, my application also works fine.

Is there a default cache manager defined by Spring? Spring docs says Spring Boot automatically configures the appropriate CacheManager.

So what will CacheManager use if we don't define it?

+4
source share
2 answers

Spring , ConcurrentHashMap. .

@EnableCaching, Spring Boot , , CacheManager. . .

+3

( ) ( ConcurrentHashMap ), :

@Bean
public CacheManager cacheManager() {
    return new org.springframework.cache.concurrent.ConcurrentMapCacheManager();
}
0

Source: https://habr.com/ru/post/1667254/


All Articles