Caching with Springboot
Caching is a part of temporary memory. It lies between the application and persistence database. It stores the recently used data that reduces the number of database hits as much as possible.
The main reason of cache is to access data in fastest manner and without making extra call. Caching improves the performance of application.
There are four types of caching.
Caching in Springboot
Cache Annotations of Spring Boot
1) @Cacheable
This is method level annotation and parameterize it with the name of the cache where the results would be stored.
2) @CacheEvict
When we don't want to populate cache with values those we do not need often. Cache can grow quite fast and at the same time large. To stop the process of caching for particular value we use this annotation. And value is passed in parameter.
3) @CachePut
This annotation can update the cache without interfering the execution.
Dependency Required for implementation of Caching in Springboot environment
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
Image credits: geeksforgeeks
Content credits: javatpoint, medium.