자바 ehcache 사용하기


사용 목적

ehcache를 사용하여 로그인한 사용자의 다국어 처리를 하기 위함

ehcache.xml

<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="ehcache.xsd" updateCheck="true"
  monitoring="autodetect" dynamicConfig="true">

    <diskStore path="java.io.tmpdir" />

    <cache name="logCache" maxElementsInMemory="10000"
        timeToIdleSeconds="600" timeToLiveSeconds="600" memoryStoreEvictionPolicy="FIFO">
    </cache>

    <cache name="authBtnCache" maxElementsInMemory="10000"
        timeToIdleSeconds="14400" timeToLiveSeconds="43200" memoryStoreEvictionPolicy="LRU">
    </cache>

    <cache name="sysMsgCache" maxElementsInMemory="10000"
        timeToIdleSeconds="0" timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU">
    </cache>

    <cache name="sysWordCache" maxElementsInMemory="10000"
        timeToIdleSeconds="0" timeToLiveSeconds="0" memoryStoreEvictionPolicy="LRU">
    </cache>

</ehcache>

설정정보

  • maxEntriesLocalHeap
    캐시가 로컬 힙 메모리에서 사용할 수있는 캐시 항목 또는 바이트의 최대값

  • timeToIdleSeconds
    Element가 지정한 시간 동안 사용(조회)되지 않으면 캐시에서 제거된다. 이 값이 0인 경우 조회 관련 만료 시간을 지정하지 않는다. 기본값은 0이다.

  • timeToLiveSeconds
    Element가 존재하는 시간. 이 시간이 지나면 캐시에서 제거된다. 이 시간이 0이면 만료 시간을 지정하지 않는다. 기본값은 0이다.

  • memoryStoreEvictionPolicy
    객체의 개수가 maxElementsInMemory에 도달했을 때,모메리에서 객체를 어떻게 제거할 지에 대한 정책을 지정한다. 기본값은 LRU이다. FIFO와 LFU도 지정할 수 있다.

태그:

카테고리:

업데이트:

댓글남기기