Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cluster Shared Cache [closed]

I am searching for a java framework that would allow me to share a cache between multiple JVMs.

What I would need is something like Hazelcast but without the "distributed" part. I want to be able to add an item in the cache and have it automatically synced to the other "group member" cache. If possible, I'd like the cache to be sync'd via a reliable multicast (or something similar).

I've looked at Shoal but sadly the "Distributed State Cache" seems like an insufficient implementation for my needs.

I've looked at JBoss Cache but it seems a little overkill for what I need to do.

I've looked at JGroups, which seems to be the most promising tool for what I need to do. Does anyone have experiences with JGroups ? Preferably if it was used as a shared cache ?

Any other suggestions ?

Thanks !

EDIT : We're starting tests to help us decide between Hazelcast and Infinispan, I'll accept an answer soon.

EDIT : Due to a sudden requirements changes, we don't need a distributed map anymore. We'll be using JGroups for a low level signaling framework. Thanks everyone for you help.

like image 902
GuiSim Avatar asked Jun 11 '09 16:06

GuiSim


People also ask

What is a clustered cache?

A cache cluster, also known as OracleAS Cluster (Web Cache), is a loosely coupled collection of cooperating Web cache instances working together to provide a single logical cache.

What is cluster shared volume used for?

Cluster Shared Volumes simplifies storage management by allowing large numbers of VMs to be accessed off a common shared disk. CSV also increases the resiliency of the cluster by having I/O fault detection and recovery over alternate communication paths between the nodes in the cluster.

Does ehcache support clustering?

Clustering conceptsThe Ehcache Clustered Tier Manager is the server-side component that gives clustering capabilities to a cache manager. Cache managers connect to these to get access to the server's storage resources so that the clustered tiers of caches defined in them can consume those resources.

Is ehcache distributed?

is a pluggable cache for Hibernate, tuned for high concurrent load on large multi-cpu servers, provides LRU, LFU and FIFO cache eviction policies, and is production tested. Ehcache is used by LinkedIn to cache member profiles.


2 Answers

How about this?

Have a local ConcurrentHashMap as your local cache. Create a Hazelcast distributed map/cache. Start listening for the distributed map events and update your local ConcurrentHashMap.

Now local caches on each member will be the same. Auto-synched.

import com.hazelcast.core.IMap;  import com.hazelcast.core.Hazelcast; import com.hazelcast.core.EntryListener; import com.hazelcast.core.EntryEvent;  import java.util.concurrent.ConcurrentHashMap;  public class Sample implements EntryListener {         Map localCache = new ConcurrentHashMap ();          public static void main(String[] args) {                  Sample sample = new Sample();                 IMap   map    = Hazelcast.getMap("default");                   //Listen for all added/updated/removed entries                 map.addEntryListener(sample, true);           }          public void entryAdded(EntryEvent event) {              localCache.put(event.getKey(), event.getValue());                     }          public void entryRemoved(EntryEvent event) {              localCache.remove(event.getKey());                     }          public void entryUpdated(EntryEvent event) {              localCache.put(event.getKey(), event.getValue());                     } } 
like image 132
Talip Ozturk Avatar answered Sep 28 '22 07:09

Talip Ozturk


Have you considered Infinispan - http://www.jboss.org/infinispan/ ? The API is very simple and based on a standard (JSR-107). The usage is also very simple

CacheManager manager = new DefaultCacheManager(                 GlobalConfiguration.getClusteredDefault() );  Cache cache = manager.getCache();  cache.put("key", "value"); 

--Hardy

like image 30
Hardy Avatar answered Sep 28 '22 08:09

Hardy