Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





Java - Code Samples

 Sample 1. Cache Hibernate Entities using EHCache

// net.sf.ehcache.Cache.Cache(String name, int maxElementsInMemory, MemoryStoreEvictionPolicy 
memoryStoreEvictionPolicy, boolean overflowToDisk, String diskStorePath, boolean eternal, long
timeToLiveSeconds, long timeToIdleSeconds, boolean diskPersistent, long
diskExpiryThreadIntervalSeconds, RegisteredEventListeners registeredEventListeners)

Ehcache employeeCache = new Cache("Employee", 1000, MemoryStoreEvictionPolicy.FIFO, false, "c:/EmployeeDiskCacheStorage", false, 300,
300, false, 30, null);

employeeCache = new SelfPopulatingCache(employeeCache, new CacheEntryFactory() {
   @Override
   public Object createEntry(Object day) throws Exception {
      Employee employee = getEmployee(1234);
   return employee;
   }
});

CacheManager.getInstance().addCache(employeeCache);

   Like      Feedback     EHCache  cache hibernate entities  CacheManager  CacheEntryFactory  SelfPopulatingCache  MemoryStoreEvictionPolicy  net.sf.ehcache.Cache



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner