Terracotta Ehcache notes

Java has a caching standard – JCache. This standard is described in the JSR-107 specification. This standardized approach makes it easier to integrate with different tools that perform the same function. Thus, Spring Boot supports JCache integration. Therefore, whatever implementation of JCache we would use, the code remains the same.

Some of the common JCache implementations is:

  • JCache Reference Implementation
  • Apache Ignite
  • Hazelcast
  • Oracle Coherence
  • Terracotta Ehcache
  • Infinispan

Terracotta Ehcache

Terracotta Ehcache is one of the JCache implementations.

The current version is 3.x. There are cases of using 2.x. There have been several releases of version 2.x recently, but this seems to be an exception.

Ehcache 3.x (org.ehcache:ehcache)

Version 3.x is an implementation of JCache. There are two types of topology in version 3.x:

  • Single-application topology
  • Distributed topology

A distributed topology has a Terracotta server that stores cache data and clients that can perform a set of standard operations on the data. I must say that only Terracotta Server can act as a server in a distributed topology. It comes in a standalone form, so it cannot be built (cannot be embedded) into your application. More information at the bottom of the page: Terracotta Server.

Ehcache 2.x (net.sf.ehcache:ehcache)

Version 2.x is not an out-of-the-box implementation of JCache. For compatibility with JCache, there is a separate artifact called Ehcache-JCache For Ehcache 2.x: ehcache / ehcache-jcache.

There are three types of topology in version 2.x:

  • Single-application topology
  • Distributed topology
  • Replicated topology

The first two options are the same with versions 3.x, but the third option, unfortunately, is no longer supported in versions 3.x. Therefore, if you are trying to find information about Ehcache 3 replication, then here it is: there is no replication in Ehcache 3, only distributed topology through the Terracotta Server available (see the previous section about Ehcache 3.x).

Its essence is that all clients are simultaneously servers, and are copied between all cluster members. Several protocols are supported by which Ehcache exchanges data:

  • RMI
  • JGroups
  • JMS
Telegram channel

If you still have any questions, feel free to ask me in the comments under this article or write me at promark33@gmail.com.

If I saved your day, you can support me 🤝

Leave a Reply

Your email address will not be published. Required fields are marked *