9

I try to find how to implement distributed caching for applications.

Ehcache already used for caching in my project, that's why I search how to solve this issue using it. But, unfortunately, it seems, that Terracotta Enterprise Suite is needed for this and it is commercial. Isn't it? Is there another solution how to use Ehcache for distributed caching (RMI or anything else)?

Gadget
  • 474
  • 1
  • 5
  • 12

3 Answers3

3

You don't need terracotta enterprise suite to cluster you Ehcache instances. So you can use clustering with Ehcache & Terracotta today, with pure OSS :

http://www.ehcache.org/documentation/configuration/distributed-cache-configuration

Edit: This link has expired. Below is the new link related to clustered cache http://www.ehcache.org/documentation/3.4/clustered-cache.html

Now if you need replication, you can use other mechanisms like RMI indeed :

http://www.ehcache.org/documentation/replication/index

Though, only the Terracotta clustering would bring you HA and features like consistency guarantees and the like...

Dexter
  • 4,036
  • 3
  • 47
  • 55
Alex Snaps
  • 1,230
  • 10
  • 10
  • 1
    I tried to use Ehcache with Terracotta OSS, but failed :( I have two nodes on separated servers (A, B). Every node have it's own ehcache.xml (CM). Every CM contains and have one cache, named TestCache, with inside. Ok, 'A' application put item to cache. Now, if 'A' will be requested again - it will return cached item successfully. But 'B' will miss cache. As I see in dev-console - Terracotta understand that it's common Cache Manager and cache also is common for both application. (Cause it shows hits and misses) Do I need to share caches manualy? – Gadget Apr 05 '12 at 18:25
  • I mean, do I need to set some additional configurations to tc-config.xml or to ehcache.xml? In all examples, 'root' element used for "sharing" of cache managers. But I have no any cacheManager fields in code. All described only inside ehcache.xml. Also, there is an 'instrumented-classes' setting in tc-config.xml. Do I need to list all Classes of cached objects manually? It looks strange if so, cause I hope that ehcache.xml should be enough. – Gadget Apr 05 '12 at 18:31
  • adding a terracottaConfig element within the ehcache one, pointing to the Terracotta server, and adding a terracotta element to each cache you want clustered should be sufficient to get you started. Are you sure the right xml file is being picked up ? – Alex Snaps Apr 08 '12 at 21:59
2

You may want to try Hazelcast as well. It is open source, distributed cache and is super easy to use.

PS: I work for Hazelcast

Fuad Malikov
  • 2,325
  • 18
  • 20
1

there are different ways to implement distributed cache using ehcache mechanism. One can be using RMI or Jgroups.

In one of the project i came through same situation and after some research i figured out Using Redis server for cache management is a easy and effective solution.

I suggesting this as a answer because if you try using ehcache it will take time and increase complexity and you can have multiple cache manager in your workspace.

Dhiraj
  • 1,430
  • 11
  • 21