
Untitled
By: a guest on
May 6th, 2012 | syntax:
None | size: 0.67 KB | hits: 12 | expires: Never
Ehcache set to eternal but forgets elements anyway?
public static void main(String[] args) {
CacheManager cacheManager = CacheManager.create();
Cache cache = new Cache(
new CacheConfiguration().name("test")
.overflowToDisk(true)
.eternal(true)
.maxBytesLocalHeap(1, MemoryUnit.MEGABYTES)
.overflowToOffHeap(false)
.maxBytesLocalDisk(100, MemoryUnit.GIGABYTES)
.maxElementsOnDisk(0)
.timeToIdleSeconds(0)
.timeToLiveSeconds(0)
.diskStorePath("E:\Data\Ehcache"));
cacheManager.addCache(cache);
for(int i = 0; i < 1000000; i++){
cache.put(new Element("key_" + i, "value_" + i));
}
System.out.println(cache.getSize());
}