N대의 WAS에서 성능을 위한 Local cache와 Memory효율을 위한 Server Cache 를 사용중이다.
Spring에서 동시에 사용해보자.
Local Cache 는 Clustring 하지않은 Ehcache,
Server Cache 는 Infinispan Server HotRoad 방식을 사용한다.
[context-cache.xml]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <!--?xml version="1.0" encoding="UTF-8"?--> xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> < cache:annotation-driven /> <!-- EHCache Local 형 --> < bean id = "ehCacheManager" class = "org.springframework.cache.ehcache.EhCacheCacheManager" > < property name = "cacheManager" > < bean class = "org.springframework.cache.ehcache.EhCacheManagerFactoryBean" > < property name = "configLocation" value = "classpath:config/cache/ehcache.xml" ></ property > </ bean > </ property > </ bean > <!-- Infinispan Server 형 --> < util:properties id = "hotrod_data" location = "classpath:properties/hotrod_data.properties" /> < bean id = "ispnCacheManager" class = "org.infinispan.spring.provider.SpringRemoteCacheManagerFactoryBean" > < property name = "configurationProperties" ref = "hotrod_data" /> </ bean > < bean id = "cacheManager" class = "org.springframework.cache.support.CompositeCacheManager" > < property name = "cacheManagers" > < list > < ref bean = "ehCacheManager" /> < ref bean = "ispnCacheManager" /> </ list > </ property > </ bean > </ beans > |
[ehcache.xml]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | <? xml version = "1.0" encoding = "UTF-8" ?> < diskStore path = "java.io.tmpdir" /> < defaultCache maxElementsInMemory = "50000" eternal = "false" timeToIdleSeconds = "300" timeToLiveSeconds = "600" overflowToDisk = "false" diskPersistent = "false" diskExpiryThreadIntervalSeconds = "120" memoryStoreEvictionPolicy = "LRU" > </ defaultCache > < cache name = "EHCACHE_MENU" maxElementsInMemory = "10000" eternal = "false" timeToIdleSeconds = "0" timeToLiveSeconds = "600" overflowToDisk = "false" diskPersistent = "false" diskExpiryThreadIntervalSeconds = "120" memoryStoreEvictionPolicy = "LRU" > </ cache > </ ehcache > |
[Service.java]
1 2 3 4 5 6 7 8 | @Cacheable ( "ISPN_EVENT" ) public Map getEvent(String eventKey) { return query... } @Cacheable ( "EHCACHE_MENU" ) public Map getMenu(String menuKey) { return query... } |