Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 6th, 2012  |  syntax: None  |  size: 0.67 KB  |  hits: 12  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Ehcache set to eternal but forgets elements anyway?
  2. public static void main(String[] args) {
  3.   CacheManager cacheManager = CacheManager.create();
  4.   Cache cache = new Cache(
  5.     new CacheConfiguration().name("test")
  6.     .overflowToDisk(true)
  7.     .eternal(true)
  8.     .maxBytesLocalHeap(1, MemoryUnit.MEGABYTES)
  9.     .overflowToOffHeap(false)
  10.     .maxBytesLocalDisk(100, MemoryUnit.GIGABYTES)
  11.     .maxElementsOnDisk(0)
  12.     .timeToIdleSeconds(0)
  13.     .timeToLiveSeconds(0)
  14.     .diskStorePath("E:\Data\Ehcache"));
  15.   cacheManager.addCache(cache);
  16.   for(int i = 0; i < 1000000; i++){
  17.     cache.put(new Element("key_" + i, "value_" + i));
  18.   }
  19.   System.out.println(cache.getSize());      
  20. }