Reputation: 568
I'm looking for a caching solution providing an automatic replication of changes using Hibernate's 2nd level cache. My use case: different cluster nodes each holding database information in Hibernate's 2nd level cache. In case of an update via the entity manager the change should be replicated to each cluster node to prevent any stale data. I've seen that ehCache 2.x has replication methods (e.g. via JGroups) which are easy to configure. Unfortunately ehCache 3.x does not support replication any more. Instead Cache-as-a-Service with Terracotta-Server is provided, which can not be used in my environment. I've also seen that version 2.x and 3.x are co-existing for a long time. Even though I'm not sure if I should use the replication feature of version 2.x.
Upvotes: 0
Views: 985
Reputation: 5888
Infinispan 2LC provider works in such a peer-to-peer mode (rather than storing data in the server). The choice of server mode was considered in the past but so far it was not worth the investment as any cache query would need to do a network roundtrip.
While Ehcache will probably integrate to Hibernate through the JCache API in the future, Infinispan provides a native (therefore more performant) integration. Here are the Maven coordinates for integration with Hibernate ORM 5.3:
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-hibernate-cache-v53</artifactId>
<version>9.3.1.Final</version>
</dependency>
If you integrate with Hibernate 5.1 use the infinispan-hibernate-cache-v51
artifact. 5.2 support (infinispan-hibernate-cache
- yes, without the suffix) has been dropped and the last release is 9.2.5.Final.
Upvotes: 1
Reputation: 5731
Yes, Ehcache 2.x should cover your use-case.
No, it won't be maintained in the future. It is barely maintained right now. It will indeed be replaced by Ehcache 3.x.
Upvotes: 0