Caching
Many times consumers request the same things, and the application returns the same information. In this scenario, caching is the solution to avoid constantly processing the same request and returning the required data faster.
Caching is used for data that does not change frequently in order to have a precalculated response without processing the request. The workflow is as follows:
The first time that the consumer requests some information, the application processes the request and gets the required data.
It saves the required data for that request in the cache with an expiration time that we define.
It returns the data to the consumer.
Next time that a consumer requests something you need to do the following:
Check whether the request is in the application cache and it has not expired.
Return the data located in the cache.
So, in our example, we will use caching in the location microservice in order to avoid requesting the closest secrets multiple times.
The first thing that we need to use...