I have a java app running on JDK 1.6.0_17 on Linux. I'm using ehcache 2.1.0, with a very simple ehcache.xml file:
<diskStore path="/ext/ehcache"/>
<defaultCache
overflowToDisk="true"
diskPersistent="true"
maxElementsInMemory="10000"
maxElementsOnDisk="1000000000"
eternal="true">
</defaultCache>
In my java app, I have this code:
private static final String CACHE_NAME = "APP";
public static void init() {
CacheManager.create();
final CacheManager manager = CacheManager.getInstance();
manager.addCache(CACHE_NAME);
}
private static Cache getCache() {
final CacheManager manager = CacheManager.getInstance();
return manager.getCache(CACHE_NAME);
}
public static Object get(String key) {
final Cache cache = getCache();
final Element element = cache.get(key);
return (element != null) ? element.getValue() : null;
}
private static void put(String key, Object value) {
final Cache cache = getCache();
final Element element = new Element(key, value);
cache.put(element);
}
If I remove the disk store file (/ext/ehcache) and start up my app, I can see that the disk store file is being written. If I do "ls -l" on the file as the app runs, "ls -l" shows that the file size is getting larger as time goes on.
I then stop my java app using "kill -15" (SIGTERM). I then restart my java app, and it seems to start up ok. The java app is continuing to store data into ehcache, but for a long time the disk store file never grows. "ls -l" always shows the same file size. After waiting for many hours, the file does start growing again.
I'm guessing that everything in the disk store is becoming invalid, and the file's content is getting repopulated. If that's the case, why is everything in the disk store being invalidated? I want to keep that data available between app restarts.