Ehcache migration from 2.6 to 3.00
Asked Answered
U

1

7

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.

Urano answered 6/2, 2017 at 15:1 Comment(2)
What are the things to keep in mind while migrating ehcache 2.x to 3.x? I'm migrating from 2.4.2 to 3.4 (current version). Is there any major changes that I need to make in source code?Lenardlenci
If you use Spring have a look here: https://mcmap.net/q/812691/-using-ehcache-3-with-spring-annotations-not-using-spring-bootPredominance
G
11

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.

Gelatinous answered 7/2, 2017 at 8:50 Comment(1)
do you know what can possibly replace the management.Cache in Ehcache 3?Chantay

© 2022 - 2024 — McMap. All rights reserved.