JCache – the standard cache of Java EE
JCache was added to Java EE to enable the application and libraries to interact in a standard manner with the caching. Therefore, it has two types of APIs and features:
- A programmatic Cache API to write/read data
- A CDI integration to automatically put data in the cache
Setting up JCache
To use JCache, you may need to add it to your application—or to your server, depending on how you want to deploy it—since not all servers add it in their distribution(s). To do it with maven, you can add this dependency:
<dependency> <groupId>javax.cache</groupId> <artifactId>cache-api</artifactId> <version>1.0.0</version> </dependency>
Then the only thing you will need to do is select an implementation and add it as well. The most common ones are the following:
- Apache Ignite
- JBoss Infinispan
- Apache JCS
- Ehcache
- Oracle Coherence
- Hazelcast
As often, the choice of the provider is a multicriteria choice and you will probably...