I have implemented 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 is absolutely working fine.
But to implement caching there should be one mandatory CacheManager / Cacheprovider defined. Without defining any cacheManager also my application is working fine.
Is there any default Cache manager defined by Spring ? Spring docs says Spring Boot auto-configures a suitable CacheManager.
So what will be CacheManager used if we do not define it ?
The Spring Boot starter provides a simple cache provider which stores values in an instance of ConcurrentHashMap. This is the simplest possible thread-safe implementation of the caching mechanism.
If the @EnableCaching
annotation is present in your app, Spring Boot checks dependencies available on your class path and configures an appropriate CacheManager
. Depending on a chosen provider, some additional configuration may be required. You can find all information about configuration in the first link from this answer.