feat: ehcache3 적용 불가 > ehcache2 minor update fix

main
minuk926 2 years ago
parent f62c6ed694
commit 8c7117f0b0

@ -513,7 +513,8 @@
<version>1.2.0</version>
</dependency>
-->
<!-- ehcache -->
<!-- ehcache3 -->
<!--
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
@ -530,6 +531,25 @@
<artifactId>cache-api</artifactId>
<version>1.1.0</version>
</dependency>
-->
<!-- ehcache2 -->
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache-core</artifactId>
<version>2.6.11</version>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>

@ -43,6 +43,7 @@ public class CacheServiceImpl implements CacheService {
return menuMapper.selectMenuListByUser(uniqId);
}
@SuppressWarnings("unchecked")
@Cacheable(cacheNames="menuCache", key = "#authorCode")
@Override
public List<Map<String, String>> findMenuListByAuthorCode(final String authorCode) {

@ -0,0 +1,34 @@
/*
package kr.xit.framework.core.config;
import java.net.URISyntaxException;
import java.net.URL;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cache.jcache.JCacheCacheManager;
import org.springframework.cache.jcache.JCacheManagerFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
//@Configuration
//@EnableCaching
public class CacheConfig3 {
@Bean
public CacheManager cacheManager() throws URISyntaxException {
return
new JCacheCacheManager(ehCacheManager().getObject());
}
@Bean
public JCacheManagerFactoryBean ehCacheManager() throws URISyntaxException {
final URL confUrl = getClass().getResource("/spring/service/cache/ehcache3.xml");
JCacheManagerFactoryBean cmfb = new JCacheManagerFactoryBean();
cmfb.setCacheManagerUri(confUrl.toURI());
//cmfb.setConfigLocation(new ClassPathResource("classpath:/spring/service/cache/ehcache3.xml"));
return cmfb;
}
}
*/

@ -1,3 +1,4 @@
/*
package kr.xit.framework.support.cache;
import org.ehcache.event.CacheEvent;
@ -12,3 +13,4 @@ public class EhCacheEventLogger implements CacheEventListener<Object, Object> {
log.info("cache event logger message::getKey: {} / getOldValue: {} / getNewValue:{}", cacheEvent.getKey(), cacheEvent.getOldValue(), cacheEvent.getNewValue());
}
}
*/

@ -7,7 +7,8 @@
<import resource="classpath:/spring/service/context-common.xml"/>
<import resource="classpath:/spring/service/context-security.xml"/>
<import resource="classpath:/spring/service/context-transaction.xml"/>
<!-- <import resource="classpath/spring/service/service/context-aspect.xml"/>-->
<!-- <import resource="classpath:/spring/service/context-aspect.xml"/>-->
<!--bean class="kr.xit.framework.core.config.EhCacheConfig3"/-->
<import resource="classpath:/spring/service/cache/context-ehcache.xml"/>
<import resource="classpath:/spring/service/context-excel.xml"/>
<import resource="classpath:/spring/service/context-beans.xml"/>

@ -1,14 +1,22 @@
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven cache-manager="ehCacheManager"/>
<bean id="ehCacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
<property name="cacheManager">
<bean class="org.springframework.cache.jcache.JCacheManagerFactoryBean"
p:cacheManagerUri="classpath:spring/service/cache/ehcache.xml" />
</property>
<cache:annotation-driven />
<!-- EHCache 기반 CacheManager 설정 -->
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="ehcache"/>
</bean>
<!--
multi-node시 shared=true property 필요 - 싱글노드시 불필요
-->
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
<property name="configLocation" value="classpath:spring/service/cache/ehcache.xml"/>
<property name="shared" value="true"/>
</bean>
</beans>

@ -0,0 +1,15 @@
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven cache-manager="ehCacheManager"/>
<bean id="ehCacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
<property name="cacheManager">
<bean class="org.springframework.cache.jcache.JCacheManagerFactoryBean"
p:cacheManagerUri="classpath:spring/service/cache/ehcache.xml" />
</property>
</bean>
</beans>

@ -1,91 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.ehcache.org/v3">
<!-- 캐시 파일이 생성되는 경로 -->
<persistence directory="${user.home}/data/cache/data"/>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
updateCheck="false"
monitoring="autodetect"
dynamicConfig="false">
<!-- dynamicConfig="true" -->
<diskStore path="java.io.tmpdir" />
<cache-template name="cacheLog">
<!-- 캐시가 생성되고 삭제되는 이벤트를 모니터링 하고 싶을 때의 설정 -->
<!-- 운영시 comment -->
<listeners>
<listener>
<class>kr.xit.framework.support.cache.EhCacheEventLogger</class> <!-- 캐싱처리에 대한 리스너가 등록된 클래스의 FQCN을 등록한다. -->
<event-firing-mode>ASYNCHRONOUS</event-firing-mode>
<event-ordering-mode>UNORDERED</event-ordering-mode>
<events-to-fire-on>CREATED</events-to-fire-on>
<events-to-fire-on>EVICTED</events-to-fire-on>
<events-to-fire-on>REMOVED</events-to-fire-on>
<events-to-fire-on>UPDATED</events-to-fire-on>
<events-to-fire-on>EXPIRED</events-to-fire-on>
</listener>
</listeners>
</cache-template>
<!--
Cache에 저장할 레퍼런스의 최대값을 100000으로 지정,
maxDepthExceededBehavior = "continue" : 초과 된 최대 깊이에 대해 경고하지만 크기가 조정 된 요소를 계속 탐색
maxDepthExceededBehavior = "abort" : 순회를 중지하고 부분적으로 계산 된 크기를 즉시 반환
-->
<sizeOfPolicy maxDepth="100000" maxDepthExceededBehavior="continue"/>
<cache alias="codeComboCache" uses-template="cacheLog"> <!-- cache name -->
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object -->
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object -->
<!-- 캐시 만료기간 -->
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos -->
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- default Cache 설정 : 필수 -->
<defaultCache
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
maxElementsOnDisk="1000000"
memoryStoreEvictionPolicy="LRU"
statistics="true">
</defaultCache>
<!-- 캐시 데이터 저장 공간과 용량 지정 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 -->
<!-- heap unit : entries, TB, GB, MB, KB, B -->
<!-- offheap unit : TB, GB, MB, KB, B -->
<resources>
<!-- 캐시 사용 갯수 지정 -->
<heap unit="entries">100</heap>
<!-- JVM heap 외부 메모리 -->
<offheap unit="MB">10</offheap>
<!-- Disk memory : shutdown시 삭제 여부 지정 -->
<disk unit="MB" persistent="false">50</disk>
</resources>
<cache name="codeCache"
maxEntriesLocalHeap="1000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
maxElementsOnDisk="1000000"
memoryStoreEvictionPolicy="LRU"
statistics="true">
</cache>
<cache alias="codeCache" uses-template="cacheLog"> <!-- cache name -->
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object -->
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object -->
<!-- 캐시 만료기간 -->
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos -->
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- 캐시 데이터 저장 공간과 용량 지정 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 -->
<!-- heap unit : entries, TB, GB, MB, KB, B -->
<!-- offheap unit : TB, GB, MB, KB, B -->
<resources>
<!-- 캐시 사용 갯수 지정 -->
<heap unit="entries">100</heap>
<!-- JVM heap 외부 메모리 -->
<offheap unit="MB">10</offheap>
<!-- Disk memory : shutdown시 삭제 여부 지정 -->
<disk unit="MB" persistent="false">50</disk>
</resources>
<cache name="codeComboCache"
maxEntriesLocalHeap="1000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
maxElementsOnDisk="1000000"
memoryStoreEvictionPolicy="LRU"
statistics="true">
</cache>
<cache alias="menuCache" uses-template="cacheLog"> <!-- cache name -->
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object -->
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object -->
<!-- 캐시 만료기간 -->
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos -->
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- 캐시 데이터 저장 공간과 용량 지정 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 -->
<!-- heap unit : entries, TB, GB, MB, KB, B -->
<!-- offheap unit : TB, GB, MB, KB, B -->
<resources>
<!-- 캐시 사용 갯수 지정 -->
<heap unit="entries">100</heap>
<!-- JVM heap 외부 메모리 -->
<offheap unit="MB">10</offheap>
<!-- Disk memory : shutdown시 삭제 여부 지정 -->
<disk unit="MB" persistent="false">50</disk>
</resources>
<cache name="menuCache"
maxEntriesLocalHeap="1000"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="0"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
maxElementsOnDisk="1000000"
memoryStoreEvictionPolicy="LRU"
statistics="true">
</cache>
</config>
</ehcache>

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xmlns='http://www.ehcache.org/v3'
xmlns:jsr107='http://www.ehcache.org/v3/jsr107'>
<service>
<jsr107:defaults enable-statistics="true"/>
</service>
<!-- 캐시 파일이 생성되는 경로 -->
<persistence directory="${user.home}/data/cache/data"/>
<cache-template name="cacheLog">
<!-- 캐시가 생성되고 삭제되는 이벤트를 모니터링 하고 싶을 때의 설정 -->
<!-- 운영시 comment -->
<listeners>
<listener>
<class>kr.xit.framework.support.cache.EhCacheEventLogger</class> <!-- 캐싱처리에 대한 리스너가 등록된 클래스의 FQCN을 등록한다. -->
<event-firing-mode>ASYNCHRONOUS</event-firing-mode>
<event-ordering-mode>UNORDERED</event-ordering-mode>
<events-to-fire-on>CREATED</events-to-fire-on>
<events-to-fire-on>EVICTED</events-to-fire-on>
<events-to-fire-on>REMOVED</events-to-fire-on>
<events-to-fire-on>UPDATED</events-to-fire-on>
<events-to-fire-on>EXPIRED</events-to-fire-on>
</listener>
</listeners>
</cache-template>
<cache alias="codeComboCache" uses-template="cacheLog"> <!-- cache name -->
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object -->
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object -->
<!-- 캐시 만료기간 -->
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos -->
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- 캐시 데이터 저장 공간과 용량 지정 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 -->
<!-- heap unit : entries, TB, GB, MB, KB, B -->
<!-- offheap unit : TB, GB, MB, KB, B -->
<resources>
<!-- 캐시 사용 갯수 지정 -->
<heap unit="entries">100</heap>
<!-- JVM heap 외부 메모리 -->
<offheap unit="MB">10</offheap>
<!-- Disk memory : shutdown시 삭제 여부 지정 -->
<disk unit="MB" persistent="false">50</disk>
</resources>
</cache>
<cache alias="menuCache" uses-template="cacheLog"> <!-- cache name -->
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object -->
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object -->
<!-- 캐시 만료기간 -->
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos -->
<expiry>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- 캐시 데이터 저장 공간과 용량 지정 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 -->
<!-- heap unit : entries, TB, GB, MB, KB, B -->
<!-- offheap unit : TB, GB, MB, KB, B -->
<resources>
<!-- 캐시 사용 갯수 지정 -->
<heap unit="entries">100</heap>
<!-- JVM heap 외부 메모리 -->
<offheap unit="MB">10</offheap>
<!-- Disk memory : shutdown시 삭제 여부 지정 -->
<disk unit="MB" persistent="false">50</disk>
</resources>
</cache>
</config>
Loading…
Cancel
Save