Giriş
Spring org.springframework.cache.jcache.JCacheCacheManager ile iletişime geçer. Bu sınıfta kendisine takılan ve JCache standardını gerçekleştiren herhangi bir kütüphaneyi kullanır. Açıklaması şöyle
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),...
Açıklaması şöyle
JCache is the standard caching API for Java. It is provided by javax.cache.spi.CachingProvider.
It is present on the classpath. The spring-boot-starter-cache provides the JCacheCacheManager.
Maven
Şöyle yaparız. İlave olarak JCache Provider'ın dependency'si de eklenir
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>javax.cache</groupId>
<artifactId>cache-api</artifactId>
</dependency>
Örnek - Hazelcast
Şöyle yaparız
debug=true
spring.cache.type=jcache
spring.cache.jcache.config=classpath:hazelcast.xml
spring.cache.jcache.provider=com.hazelcast.cache.impl.HazelcastServerCachingProvider
Örnek - Hazelcast
Şöyle yaparız
# Configure the cache
#spring.cache.jcache.provider=com.hazelcast.client.cache.HazelcastClientCachingProvider
spring.cache.jcache.provider=com.hazelcast.cache.HazelcastMemberCachingProvider
Örnek - XML ile Hazelcast
Şöyle yaparız. Burada JCache Standardını gerçekleştiren org.springframework.cache.jcache.JCacheCacheManager nesnesine bir com.hazelcast.cache.HazelcastCacheManager nesnesi geçiliyor<cache:annotation-driven cache-manager="cacheManager" />
<hz:hazelcast id="instance">
...
</hz:hazelcast>
<hz:cache-manager id="hazelcastJCacheCacheManager" instance-ref="instance"
name="hazelcastJCacheCacheManager"/>
<bean id="cacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
<constructor-arg ref="hazelcastJCacheCacheManager" />
</bean>
Hiç yorum yok:
Yorum Gönder