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

main
minuk926 2 years ago
parent f62c6ed694
commit 8c7117f0b0

@ -513,7 +513,8 @@
<version>1.2.0</version> <version>1.2.0</version>
</dependency> </dependency>
--> -->
<!-- ehcache --> <!-- ehcache3 -->
<!--
<dependency> <dependency>
<groupId>org.ehcache</groupId> <groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId> <artifactId>ehcache</artifactId>
@ -530,6 +531,25 @@
<artifactId>cache-api</artifactId> <artifactId>cache-api</artifactId>
<version>1.1.0</version> <version>1.1.0</version>
</dependency> </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); return menuMapper.selectMenuListByUser(uniqId);
} }
@SuppressWarnings("unchecked")
@Cacheable(cacheNames="menuCache", key = "#authorCode") @Cacheable(cacheNames="menuCache", key = "#authorCode")
@Override @Override
public List<Map<String, String>> findMenuListByAuthorCode(final String authorCode) { 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; package kr.xit.framework.support.cache;
import org.ehcache.event.CacheEvent; 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()); 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-common.xml"/>
<import resource="classpath:/spring/service/context-security.xml"/> <import resource="classpath:/spring/service/context-security.xml"/>
<import resource="classpath:/spring/service/context-transaction.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/cache/context-ehcache.xml"/>
<import resource="classpath:/spring/service/context-excel.xml"/> <import resource="classpath:/spring/service/context-excel.xml"/>
<import resource="classpath:/spring/service/context-beans.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: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 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"> http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
<cache:annotation-driven cache-manager="ehCacheManager"/> <cache:annotation-driven />
<bean id="ehCacheManager" class="org.springframework.cache.jcache.JCacheCacheManager">
<property name="cacheManager"> <!-- EHCache 기반 CacheManager 설정 -->
<bean class="org.springframework.cache.jcache.JCacheManagerFactoryBean" <bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
p:cacheManagerUri="classpath:spring/service/cache/ehcache.xml" /> <property name="cacheManager" ref="ehcache"/>
</property> </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> </bean>
</beans> </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"?> <?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://www.ehcache.org/v3"> <ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<!-- 캐시 파일이 생성되는 경로 --> xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
<persistence directory="${user.home}/data/cache/data"/> updateCheck="false"
monitoring="autodetect"
dynamicConfig="false">
<!-- dynamicConfig="true" -->
<cache-template name="cacheLog"> <diskStore path="java.io.tmpdir" />
<!-- 캐시가 생성되고 삭제되는 이벤트를 모니터링 하고 싶을 때의 설정 -->
<!-- 운영시 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 --> Cache에 저장할 레퍼런스의 최대값을 100000으로 지정,
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object --> maxDepthExceededBehavior = "continue" : 초과 된 최대 깊이에 대해 경고하지만 크기가 조정 된 요소를 계속 탐색
<!-- 캐시 만료기간 --> maxDepthExceededBehavior = "abort" : 순회를 중지하고 부분적으로 계산 된 크기를 즉시 반환
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos --> -->
<expiry> <sizeOfPolicy maxDepth="100000" maxDepthExceededBehavior="continue"/>
<ttl unit="minutes">5</ttl>
</expiry>
<!-- 캐시 데이터 저장 공간과 용량 지정 --> <!-- default Cache 설정 : 필수 -->
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 --> <defaultCache
<!-- heap unit : entries, TB, GB, MB, KB, B --> maxEntriesLocalHeap="10000"
<!-- offheap unit : TB, GB, MB, KB, B --> eternal="false"
<resources> timeToIdleSeconds="0"
<!-- 캐시 사용 갯수 지정 --> timeToLiveSeconds="0"
<heap unit="entries">100</heap> overflowToDisk="false"
<!-- JVM heap 외부 메모리 --> diskPersistent="false"
<offheap unit="MB">10</offheap> diskExpiryThreadIntervalSeconds="120"
<!-- Disk memory : shutdown시 삭제 여부 지정 --> maxElementsOnDisk="1000000"
<disk unit="MB" persistent="false">50</disk> memoryStoreEvictionPolicy="LRU"
</resources> statistics="true">
</cache> </defaultCache>
<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>
<!-- 캐시 데이터 저장 공간과 용량 지정 --> <cache name="codeCache"
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 --> maxEntriesLocalHeap="1000"
<!-- heap unit : entries, TB, GB, MB, KB, B --> eternal="false"
<!-- offheap unit : TB, GB, MB, KB, B --> timeToIdleSeconds="0"
<resources> timeToLiveSeconds="0"
<!-- 캐시 사용 갯수 지정 --> overflowToDisk="false"
<heap unit="entries">100</heap> diskPersistent="false"
<!-- JVM heap 외부 메모리 --> diskExpiryThreadIntervalSeconds="120"
<offheap unit="MB">10</offheap> maxElementsOnDisk="1000000"
<!-- Disk memory : shutdown시 삭제 여부 지정 --> memoryStoreEvictionPolicy="LRU"
<disk unit="MB" persistent="false">50</disk> statistics="true">
</resources>
</cache> </cache>
<cache alias="menuCache" uses-template="cacheLog"> <!-- cache name --> <cache name="codeComboCache"
<key-type>java.lang.Object</key-type> <!-- 캐시의 키의 FQCN 지정. 기본 값은 java.lang.Object --> maxEntriesLocalHeap="1000"
<value-type>java.lang.Object</value-type> <!-- Cache 인스턴스에 저장되는 값의 FQCN. 기본 값은 java.lang.Object --> eternal="false"
<!-- 캐시 만료기간 --> timeToIdleSeconds="0"
<!-- unit : days, hours, minutes, seconds, millis, micros, nanos --> timeToLiveSeconds="0"
<expiry> overflowToDisk="false"
<ttl unit="minutes">5</ttl> diskPersistent="false"
</expiry> diskExpiryThreadIntervalSeconds="120"
maxElementsOnDisk="1000000"
memoryStoreEvictionPolicy="LRU"
statistics="true">
</cache>
<!-- 캐시 데이터 저장 공간과 용량 지정 --> <cache name="menuCache"
<!-- 만약 힙 메모리만 사용한다면 <heap> 요소만으로 대체 가능 --> maxEntriesLocalHeap="1000"
<!-- heap unit : entries, TB, GB, MB, KB, B --> eternal="false"
<!-- offheap unit : TB, GB, MB, KB, B --> timeToIdleSeconds="0"
<resources> timeToLiveSeconds="0"
<!-- 캐시 사용 갯수 지정 --> overflowToDisk="false"
<heap unit="entries">100</heap> diskPersistent="false"
<!-- JVM heap 외부 메모리 --> diskExpiryThreadIntervalSeconds="120"
<offheap unit="MB">10</offheap> maxElementsOnDisk="1000000"
<!-- Disk memory : shutdown시 삭제 여부 지정 --> memoryStoreEvictionPolicy="LRU"
<disk unit="MB" persistent="false">50</disk> statistics="true">
</resources>
</cache> </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