
Retrieve a cache entry by using the get method. Add a cache entry by using the put method. NamedCache cache = CacheFactory.getCache ( "VirtualCache") Ī NamedCache is a instance that holds resources that are shared across nodes in a cluster. Use the cache name VirtualCache, which is mapped to a distributed caching scheme. Import the CacheFactory class and the NamedCache interface.Ĭreate the cache ( NamedCache) instance by using the CacheFactory. See "Creating a Java Class" for detailed information on creating a class.Ĭreate a cache in the CoherenceCache Java class. Click Finish.Ĭreate a Java class, CoherenceCache, that will be used to create a Coherence cache. In the Coherence page, ensure that Coherence12.1.3, Oracle Database Driver, and TopLink are selected.
#Oracle coherence cache tutorial driver
(Note, this assumes that the database connection that you created is still running.) Select Add Driver Library to Build Path and select Oracle Database Driver Default from the drop-down list. Click the Connect link to connect to the Oracle Database if necessary. In the Connection field, select the connection you created in "Configure the Project for JPA" (XE_HR), from the Connection drop down list. Ensure that Coherence12.1.3, Oracle Database Driver, and TopLink are selected under User Libraries. In the JPA Facet page, ensure that EclipseLink 2.5.x appears in the Platform field. Select the JPAConfiguration you created in Chapter 8, "Using JPA with Coherence." Use the JPA perspective in Eclipse to create a JPA Project called Interaction. To create a Java class that constructs a Coherence cache: Table 9-1 describes some of the cache types commonly used by Coherence.ĩ.2.1 Create an Application that Constructs a Cache

Cache types are defined in the caching-schemes element. Cache names and name patterns are mapped to cache types in the caching-scheme-mapping element using the subelement cache-mapping. The root element of the cache configuration file is cache-config. Whichever type of cache is used, an application uses the same API to access and store data.Ī cache configuration deployment descriptor is used to configure a cache. Failover is implemented in a distributed cache using backups, which are also distributed across the cluster nodes.Ĭoherence is implemented by using services such as the cluster service, the distributed cache service, and the replicated cache service. The drawback of replicated caches is that they require a large amount of memory because every node has a copy of every object.ĭistributed (or partitioned) caches, where data is distributed (load-balanced) across different nodes. This type of cache is recommended if faster read access is required but not suitable for write operations, because data must be written to each of the nodes. Replicated caches, where data is replicated to each of the application server nodes in the cluster. The state of data objects in a cache can be monitored and actions invoked on other processes such as the start of a business process execution language (BPEL) process.Ĭoherence supports different types of caches:

Even if the database or an application server node is not available, database updates are still reliable due to the lazy load and lazy write mechanism used by a Coherence cache and due to the failover and fail back provided by Coherence.Ĭoherence caches provide distributed processing not only across a cluster of application server nodes but also across the data objects in the cache, because data modification operations can be performed on the data objects.Ĭoherence also provides event-based processing. Modifications made to a cache can be synchronized with the database whenever the database is available. Thus, Coherence caches reduce load on the database and provide faster access to database data.Ĭoherence caches provide higher availability through database isolation and data replication. Database data can be loaded into a cache and made available to different applications.


A Coherence cache is a collection of data objects that acts as an intermediary between the database and the client applications.
