Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ehcache migration from 2.6 to 3.00

I am trying to upgrade Ehcache for my Project from 2.6 to 3.0 version.

Any replacement for net.sf.ehcache.Element and CacheExceptionHandler.

Less documentation on Ehcache 3, Can anyone give some tips for upgrading Ehacahe to version 3.

like image 243
Cork Kochi Avatar asked Feb 06 '17 15:02

Cork Kochi


People also ask

Is Ehcache still used?

JAVA'S MOST WIDELY-USED CACHE Ehcache is an open source, standards-based cache that boosts performance, offloads your database, and simplifies scalability. It's the most widely-used Java-based cache because it's robust, proven, full-featured, and integrates with other popular libraries and frameworks.

Is Ehcache in memory cache?

In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs and other very useful features.

Does Ehcache use heap?

Data stores supported by Ehcache include: On-Heap Store - Utilizes Java's on-heap RAM memory to store cache entries. This tier utilizes the same heap memory as your Java application, all of which must be scanned by the JVM's garbage collector.

Is Ehcache persistent?

Open-source Ehcache offers a limited version of persistence, as noted in this document. Fast Restart provides enterprise-ready crash resilience with an option to store a fully consistent copy of the cache on the local disk at all times.


1 Answers

Ehcache 3 is by design a major rework of the APIs so there are indeed large differences with Ehcache 2.x.

  • net.sf.ehcache.Element has been completely removed, the org.ehcache.Cache API is now closer (but not identical) to a java.util.concurrent.ConcurrentMap. This means you simply put(K key, V value) and V get(K key) - no need for a wrapper object.
    • A consequence of that is that you can no longer set a per mapping expiration. However, a custom org.ehcache.expiry.Expiry can be configured which can have mapping specific answers.
  • The concept of CacheExceptionHandler is gone. In Ehcache 3 the approach is that a Cache should never be the source of an exception. If a get fails, it is valid to return null as long as you always return that until the next put. If a put fails, there is effectively no difference with a valid put followed by immediate eviction. Ehcache 3 follows these principles. However there are cache setups, mostly around cache-through and distributed caches, where consistency can be a challenge. Expect a solution to this to come soon to the Ehcache 3.x line.

As for a more complete documentation on the topic of migrating from one to the other, that is indeed something that still needs to be done.

like image 183
Louis Jacomet Avatar answered Oct 02 '22 06:10

Louis Jacomet