Viktor
Viktor

Reputation: 1487

replicated ehcache on Glassfish

I am afraid I have got some pretty basic questions about ehcache. I would like to use caching mechanism on clustered Glassfish without any significant infrastrucure. As I know using ditributed cache with ehcache means that I have to use the terracotta server array, don't?

I am not so experienced in caching so could I use the ehcache on clustered glassfish that I just put some JAR into the classpath of Glassfish or deploy a WAR or something onto Glassfish and that's it? Do I have to use an external cache server anyway?

The replicated cache in ehcache doesn't need the terracotta server array, do it?

I would like to store a java Map object in the store which is going to be changed quite often. In this case the replicated cache is not best choice, as I know. The Hazelcast distributed cache needs any external cache server? Thank you very much for your help in advance! Have a nice day, experts!

Upvotes: 1

Views: 1139

Answers (2)

Fabian Ritzmann
Fabian Ritzmann

Reputation: 1715

The replication feature in Ehcache does not require any server. You simply add the Ehcache jar to your web application and configure Ehcache to replicate to all cluster nodes. You can choose whether to automatically discover all GlassFish nodes using multicast or you can manually tell Ehcache where to find the other nodes. You can find the Ehcache replication configuration instructions here: http://ehcache.org/documentation/replication/rmi-replicated-caching#configuring-the-peer-provider

Hazelcast works similarly. See here for documentation: http://hazelcast.org/docs/3.0/manual/html/ch12s02.html

Upvotes: 1

Fuad Malikov
Fuad Malikov

Reputation: 2345

Hazelcast doesn't need any externel server if you are running Java. Basically add hazelcast.jar into your classpath. And from your application creata an Hazelcast instance:

HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance(new Config());

then to get a distributed map:

Map map = hazelcast.getMap("myMap");

that's it. In this example I provided the default config which uses Multicast to discovery of the nodes. You can update and change any parameter.

For more information see Quick Start Tutorial

Upvotes: 1

Related Questions