It took 13 years, but as of Monday, the Java programming language has an official caching API. It’s called JCache, and it is already exerting an impact on the channel, with the announcement by open source in-memory computing vendor Hazelcast of an implementation of JCache that could have important implications for the cloud, Big Data and beyond.
Simply put, JCache makes it easy for programmers writing Java applications to cache application data, which can significantly boost performance in many cases. Caching is especially important when dealing with the immense and ever-changing scale of information demanded by cloud-based apps and Big Data infrastructure.
The Java Caching API defines five core interfaces: CachingProvider, CacheManager, Cache, Entry and ExpiryPolicy.
A CachingProvider defines the mechanism to establish, configure, acquire, manage and control zero or more CacheManagers. An application may access and use zero or more CachingProviders at runtime.
A CacheManager defines the mechanism to establish, configure, acquire, manage and control zero or more uniquely named Caches all within the context of the CacheManager. A CacheManager is owned by a single CachingProvider.
A Cache is a Map-like data-structure that permits the temporary storage of Key-based Values, some what like java.util.Map data-structure. A Cache is owned by a single CacheManager.
An Entry is a single key-value pair stored by a Cache .
Each entry stored by a cache has a defined duration, called the Expiry Duration, during which they may be accessed, updated and removed. Once this duration has passed, the entry is said to be Expired. Once expired, entries are no longer available to be accessed, updated or removed, just as if they never existed in a cache. Expiry is set using an ExpiryPolicy.