Spring JCache (JSR-107) Caching
JCache (JSR-107)
JCache is bootstrapped through the presence of a javax.cache.spi.CachingProvider on the classpath(that is, a JSR-107 compliant caching library exists on the classpath), and the JCacheCacheManager is provided by the spring-boot-starter-cache “Starter”. Various compliant libraries are available, and
Spring Boot provides dependency management for Ehcache 3, Hazelcast, and Infinispan. Any other
compliant library can be added as well.
It might happen that more than one provider is present, in which case the provider must be
explicitly specified. Even if the JSR-107 standard does not enforce a standardized way to define the
location of the configuration file, Spring Boot does its best to accommodate setting a cache with
implementation details, as shown in the following example:
# Only necessary if more than one provider is present
spring.cache.jcache.provider=com.acme.MyCachingProvider
spring.cache.jcache.config=classpath:acme.xml
There are two ways to customize the underlying javax.cache.cacheManager:
• Caches can be created on startup by setting the configprop:spring.cache.cache-names[]
property. If a custom javax.cache.configuration.Configuration bean is defined, it is used to
customize them.
• org.springframework.boot.autoconfigure.cache.JCacheManagerCustomizer beans are invoked with
the reference of the CacheManager for full customization.
If a standard javax.cache.CacheManager bean is defined, it is wrapped automatically
in an org.springframework.cache.CacheManager implementation that the abstraction
expects. No further customization is applied to it.
Comments
Post a Comment