🙇🏻 - 이동욱
🙇🏻 - dveamer
🙇🏻♂️ - jaehun2841
- build.gradle
implementation 'net.sf.ehcache:ehcache:2.10.3'
- ehcache.xml
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd"
maxBytesLocalHeap="300M" <!-- CacheManager에 의해 관리되는 캐시의 메모리를 300M로 제한 -->
updateCheck="false">
<!-- 임시저장 경로를 설정 -->
<diskStore path="java.io.tmpdir" />
<!--
Cache에 저장할 레퍼런스의 최대값을 100000으로 지정,
maxDepthExceededBehavior = "continue" : 초과 된 최대 깊이에 대해 경고하지만 크기가 조정 된 요소를 계속 탐색
maxDepthExceededBehavior = "abort" : 순회를 중지하고 부분적으로 계산 된 크기를 즉시 반환
-->
<sizeOfPolicy maxDepth="100000" maxDepthExceededBehavior="continue"/>
<!-- default Cache 설정 (반드시 선언해야 하는 Cache) -->
<defaultCache
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="1200"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU">
</defaultCache>
<!-- 사용하고자 하는 캐시 별 설정 -->
<cache name="LocalCacheData"
eternal="false"
timeToIdleSeconds="0"
timeToLiveSeconds="1200"
overflowToDisk="false"
diskPersistent="false"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU">
</cache>
@EnableCaching
: 프로젝트에서 캐시 관련 어노테이션을 사용하겠다는 선언.@Cacheable(value="findMemberCache", key="#name")
: ehcache.xml에서 지정한 findMemberCache 캐시를 사용하겠다는 의미이며, 여기서 key는 메소드 argument인 name을 사용하겠다는 의미이다.@CacheEvict(value = "findMemberCache", key="#name")
: 해당 캐시 내용을 지우겠다는 의미.