How it works...

Most of the time, distributed database architecture is an option to optimize monolithic databases in a clustered enterprise ecosystem. With this setup, some servers, which can house microservices, may share data through their own models of data communication. Now, this recipe provides another solution for optimizing data operations by setting up a distributed data caching, instead of distributed databases in a distributed ecosystem of microservices.

Spring Boot 2.0 offers a built-in HazelcastAutoConfiguration class, which does not require a separate caching server just to establish the nodes of Hazelcast cache instances. Once applications or microservices that have Hazelcast caches are deployed, their instances will autodiscover each other and will form a cluster. Instead of connecting to the dedicated data source, a cluster can just provide a reference to the Hazelcast node of another service box to retrieve data in that cache.

As we all know, Hazelcast is a popular distributed in-memory tool popular for any grid project when it comes to caching. Its most important API, which is com.hazelcast.core.HazelcastInstance, can be configured either by using an XML file or a Java Configuration class just like in this recipe. If XML configuration is used, drop the file in srcmain esources and register its location in application.properties through the spring.hazelcast.config property.

If there is no plan for building, distributed applications or microservices, using Ehcache is already a perfect data caching solution to optimize huge data retrieval.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
13.59.48.161