JCache and Infinispan – standardize your application's cache
With the adoption growth of Infinispan, its community has been resurrecting works on the quite old, but stalled, JSR-107, aka JCache. The first step was obviously the released of the JSR 1.0 version, a few month back, and most recently in December with Infinispan 7.0.2.Final is a certified JSR-107 1.0 implementation. It’s actually quite useful news, as it allows you to build webapps or even JEE apps using a standard API to access Infinispan.
Using JCache API is pretty straightforward, fairly well documented, and to summarize consists of:
- add a dependency to infinispan-jcache artifact
Everything you need to grow your career.
With your free Red Hat Developer program membership, unlock our library of cheat sheets and ebooks on next-generation application development.SIGN UP
<version>...</version> <!-- i.e. 7.0.0.Final -->
- retrieve a cache manager instance coming from javax.cache (and no longer a org.infinispan specific API)
- use a pretty straightforward API, very close to Infinispan ones, to store and retrieve value:
String value = cache.get("hello"); // Returns "world"
What is excellent by this very simple news and integration is that people can now leverage, in a standard way, any caching technologies. It’s great news from a development framework, such as JBoss Seam, which previously was forced to integrate to numerous “cache providers” in order to provide a generic API for caching.
In the near future, as sadly JCache did not make it in JEE 7, JEE application server will be required to provide support for such implementation, which means that Wildfly users (or JBoss EAP) for instance, will be able to leverage most of the basic features of Infinispan without coupling its code to it.
This new API will also allow ORM frameworks, such as hibernate, to leverage JCache API to implement second level caching and no longer be forced to embedded their own implementation (or some other project, such as Infinispan).
An other excellent side effect is that, while using a very simple API within its application code, one will be able to leverage many powerful features of Infinispan, in terms of high-availability, data replication, and so on. For most ops people, Java caching technology will become less of a “black box”, but more of a powerful tool they can leverage to make their life easier.
Bottom line, I found this new integration to be actually quite exciting, as I expect it to greatly facilitate Infinispan adoption – and also create opportunities for Red Hat customers using JBoss EAP and JBoss Data Grid.