요구 사항 : 캐싱 중에 캐싱을 위해 제공된 최대 힙 크기가 초과되면 디스크로 오버 플로우되어 그곳에서 가져와야합니다. 내으로 Ehcache 구성 :스프링 ehcache - 디스크에서 캐시를 검색하지 않습니다.
cache:
timeToLiveSeconds: 3600
ehcache:
maxBytesLocalHeap: 1M
setMaxBytesLocalDisk: 5G
diskStore: cacheDiskStore
이 (이상 YML에서 제공하는 값으로 타게되는) ehcache.xml 구성입니다 :
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd" name="CM1"
updateCheck="false" maxBytesLocalHeap="1M" maxBytesLocalDisk="1M" maxEntriesLocalDisk="100000">
<!-- This is a default configuration, it is re-configured by the CacheConfiguration
Spring Bean, using the properties from the resources/config/*.yml files. -->
<diskStore path="cacheDiskStore" />
<defaultCache eternal="false" overflowToDisk="true" />
<cache name="cache1" >
<persistence strategy="localTempSwap" />
</cache>
<cache name="cache2" >
<persistence strategy="localTempSwap" />
</cache>
내가 큰 미디어 파일을 캐싱하고있다. 하지만 캐시에서 Element를 검색하려고하면 항상 null이됩니다. 이것은 캐시에서 검색하는 방법입니다.
Element elt = CacheManager.getInstance()
.getEhcache("<cacheName>").get(<key>);
if (elt != null) {
System.out.println("**** Retrieved from cache *****");
return elt;
} else {
System.out.println("**** NOT FOUND IN CACHE *****");
return null;
}
캐시에서 가져 오지 않습니다. 캐시 힙 크기를 늘리면 제대로 작동합니다.. 어떤 도움이 필요합니까?
안녕하세요. 감사. 그러면이 퇴거는 어떻게 피할 수 있습니까? – hack
힙 크기를 늘려 캐시 공간을 넓히면 자신의 질문에 자신을 진술합니다. 유스 케이스에 가장 적합한 정확한 양과 테스트가 결정되어야합니다. –