Pricing
Chat
Contact

JCache / Java Cache

JCache is a de facto standard Java cache API for caching data. Also known as JSR 107 (i.e., a “Java Specification Request” from the “Java Community Process” [JCP]), this API implementation is intended to create a way for different technologies to provide a common caching interface. It defines the mechanism for creating, accessing, updating, and removing information from a cache. This common interface makes it easier for software developers to leverage a variety of technologies as caches since the software they write using JSR 107 does not need to be rewritten to work with the different underlying technology.

How Does JCache Work?

JCache uses the top-level package name of javax.cache, and defines the following five core interfaces:

  • Cache. This defines access to the actual cache, which is a map-like data structure that stores key-value pairs.
  • Entry. This defines access to the key-value pairs stored in the cache.
  • CacheManager. This defines how caches are managed.
  • CachingProvider. This defines how CachingManagers are managed.
  • ExpiryPolicy. This defines how expiration is handled for entries.

These interfaces give developers fine-grained controls on how the cache is used. Any technology that implements JSR 107 should adhere to the requirements in the specification, though there are many implementation details that are not covered that the underlying technology is free to implement in its own way. For example, this specification does not describe how data should be stored in caches, nor does it describe how data in the cache should be secured.

There are two defined mechanisms in which an entry can be stored in a cache. The default mechanism is called store-by-value, in which the key-value pairs are stored in the cache, and new copies of the entries are made and returned when accessed from the cache. The other (optional) mechanism is store-by-reference, in which the cache stores and returns reference to application-provided key-value pairs. This lets updates to the application-provided key-value pairs to be seen in subsequent accesses without having to update the cache entries themselves.

Hazelcast is an example of an in-memory computing platform that implements JCache following the specification described in JSR 107. (Incidentally, the CTO of Hazelcast, Greg Luck, is one of the creators of JSR 107.) Any existing application that writes to the JCache API can leverage Hazelcast to get extremely high caching performance along with resiliency, data consistency, and data security.