Caching with Springboot

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.

  • In-memory Caching
  • Database Caching
  • Web server Caching
  • CDN 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.

To view or add a comment, sign in

More articles by Saurabh Gadekar

  • DB with Spring boot

    *Configuration for connecting db to springboot application -need to configure application.yml file inside application…

  • Basic Authentication and JWT with Springboot

    Authentication and Authorization Authentication is the process of verifying who is user, while authorization is the…

  • Multithreading in Java

    process: Any active execution thread: thread is lightweight sub process. using two ways we can implement: 1) Runnable…

  • Service Discovery in Microservices

    Service Discovery is the automatic detection of devices and services offered by these devices on a computer network. In…

  • Autowiring with @Qualifier and @Primary Annotations in Springboot

    @Autowired is a mechanism by which Spring Boot automatically resolves and injects collaborating beans into your…

  • Scheduling in Springboot

    Job scheduling is a crucial aspect of many applications, especially when it comes to automating repetitive tasks…

  • Logging in Springboot

    In spring boot application logging plays important role to keep track on all the actions, activities and events…

  • Rest Template

    RestTemplate is a powerful synchronous client for handling HTTP communication in Spring Boot applications. Internally…

  • Fault tolerance in Microservices

    Preventing system from temporary or permanent failure is the purpose of fault tolerance. In microservices environment…

  • Actuator

    Dependency required: org.springframework.

Insights from the community

Others also viewed

Explore topics