I am trying to do a simple thing like store something in the cache and retrieve it next time if it exists. For some reason everything works fine for the first time, when called the second time, everything in the cache file is removed and the cache is created again. Here is my ehcache config file
<ehcache>
<diskStore path="<TEMP_DIR_PATH>" />
<defaultCache maxElementsInMemory="10000" eternal="true"
timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
maxElementsOnDisk="10000000" diskPersistent="true"
diskExpiryThreadIntervalSeconds="120" memoryStoreEvictionPolicy="LRU" />
<cache name="mycache" maxElementsInMemory="1" eternal="true"
overflowToDisk="true" timeToIdleSeconds="300" timeToLiveSeconds="600"
diskPersistent="true" diskExpiryThreadIntervalSeconds="1"
memoryStoreEvictionPolicy="LFU"/>
</ehcache>
The code actually creates 2 files one named mycache.index and the other named mycache.data. The code to put the value in to cache is given below.
Cache cache = cacheManager.getCache("mycache");
Element myElement= new Element("KEY1","This will be stored in cache");
cache.put(myElement);
Could someone please point out where things are going wrong?
I wanted to use the same stored cache file everytime and create a new file only if the data file is not present.