Configuring the cache storage
Spring's cache abstraction provides a lot of storage integration. Spring provides CacheManager
for each memory storage. You can just configure CacheManager
with the application. Then the CacheManager
is responsible for controlling and managing the Caches. Let's explore how to set up the CacheManager
in an application.
Setting up the CacheManager
You must specify a cache manager in the application for storage, and some cache provider given to the CacheManager
, or you can write your own CacheManager
. Spring provides several cache managers in the org.springframework.cache
package, for example, ConcurrentMapCacheManager
, which creates a ConcurrentHashMap
for each cache storage unit.
@Bean public CacheManager cacheManager() { CacheManager cacheManager = new ConcurrentMapCacheManager(); return cacheManager; }
SimpleCacheManager
, ConcurrentMapCacheManager
, and others are cache managers of the Spring Framework's cache abstraction. But Spring...