New User: ehcache doesn't seem to save to disk

View: New views
1 Messages — Rating Filter:   Alert me  

New User: ehcache doesn't seem to save to disk

by falcon :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,
I just downloaded ehcache 1.6 and am testing it on Java 1.6 (windows).
In my test, I am writing data to a cache, that cache seems to write something to disk (I can see something in the .index file, although .data file is empty).  Even after I shutdown the JVM, the index file has the same data.  When I run my program again, the index file gets reset to zero bytes and it shows that I have nothing in the cache!

What am I doing wrong?

-----------------My config file (comments, test caches, xml boiler plate, etc. removed):
<diskStore path="data"/>
<cacheManagerEventListenerFactory class="" properties=""/>
<cacheManagerPeerProviderFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerProviderFactory"
            properties="peerDiscovery=automatic,
                        multicastGroupAddress=230.0.0.1,
                        multicastGroupPort=4446, timeToLive=1"
            propertySeparator=","
            />
<cacheManagerPeerListenerFactory
            class="net.sf.ehcache.distribution.RMICacheManagerPeerListenerFactory"/>
<defaultCache
            maxElementsInMemory="10000"
            eternal="true"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskSpoolBufferSizeMB="30"
            maxElementsOnDisk="0"
            diskPersistent="true"
            diskExpiryThreadIntervalSeconds="0"
            memoryStoreEvictionPolicy="LRU"
            />
<cache name="cache1"
    maxElementsInMemory="10000"
            eternal="true"
            timeToIdleSeconds="120"
            timeToLiveSeconds="120"
            overflowToDisk="true"
            diskSpoolBufferSizeMB="30"
            maxElementsOnDisk="0"
            diskPersistent="true"
            diskExpiryThreadIntervalSeconds="0"
            memoryStoreEvictionPolicy="LRU"
            />

-------My Test Code----------
package test;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import QUOTE;//import quote data type from my internal package heirarchy, taken out here

import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;

public class EHCacheTest {

        /**
         * @param args
         */
        public static void main(String[] args) {
                CacheManager manager = new CacheManager("config/ehcache.xml");

                Cache cache1=manager.getCache("cache1");
               
                int size=1000000;

                System.out.println("Size of cache is "+cache1.getSize());
               
                for(int i=0;i<size;i++){
                        String id =Util.newOrderID();
                        cache1.put(new Element(id,new QUOTE("x",23.23,3434l)));
                }

                System.out.println("Size of cache is "+cache1.getSize());
               
                manager.shutdown();
        }
}

Thanks