Oracle Coherence is a memory-based data grid powered by Java, or just say a caching system like those Memcached or Redis, but with a lot more features including clustered environment, data replication, distributed services, persistence etc.

Let’s start trying out Oracle Coherence.
First I downloaded the pre-built VM from Oracle Website which includes everything you need to develop an Enterprise Java application, from weblogic to Oracle Database.

To start the Oracle Coherence

Navigate to Coherence Installation path : cd /labs/wls1035/coherence_3.6/

Start cache server : bin/cache-server.sh

Let’s tryout some examples

first you need to start Coherence Client (from coherence installation path): bin/coherence.sh

Map (?): cache mycache

Map (mycache): put sample value
null

Map (mycache): get sample
value

and let’s try the data replication feature (out-of-the-box) by start another instance of Oracle coherence (from the same path as above) and close the previous coherence instance and do the “get sample” again, amazing huh? The Oracle coherence also supports Partitioned cluster.

Working with Netbeans

Netbeans itself doesn’t support Oracle coherence out-of-the-box, however, there’s a plugin available for download via Plugins Menu. (Just search coherence)

To start coherence for netbeans

goes to Services tab, you will see Coherence Servers Icon:

Right Click -> add Coherence Server

Put in a server name

Select Properties on the server

insert “/labs/wls1035/coherence_3.6/lib/coherence.jar” in to Coherence Classpath.

and that is click start and  done.

You could clone the server and start another instance of it, as easy as a pie.

Using Coherence API.

NamedCache mycache = CacheFactory.getCache(“test”);

mycache.put(“test”, “value”);

mycache.get(“test”);

Is that simple? Yes, but there are a lot more options you could do with Coherence via XML file.