Caching is essential in order to build a performant application. You would not want to hit the external service or the database all the time. Data that does not change frequently can be cached.
Spring provides transparent mechanisms to connect and use a Cache. The following steps are involved in enabling a cache on an application:
- Add the Spring Boot Starter Cache dependency.
- Add caching annotations.
Let's discuss these in detail.