1. Overview
In this article, we will introduce Ehcache, a widely used, open-source Java-based cache. It features memory and disk stores, listeners, cache loaders, RESTful and SOAP APIs, and other very useful features.
To show how caching can optimize our application, we will create a simple method that will calculate the square values of provided numbers. On each call, the method will call the .calculateSquareOfNumber() method and print an information message to the console.
With this simple example, we want to show that the calculation of squared values is done only once, and every other call with the same input value returns results from the cache.
It’s important to notice that we’re focused entirely on Ehcache itself (without Spring); if you want to see how Ehcache works with Spring, have a look at this article.