简体   繁体   中英

How to implement caching for cluster setup in java springboot?

I want to implement cache for my service, so I used spring-boot-starter-cache in my application. But we have cluster setup(2 nodes) and currently if the request is going to one node it is not updating the other node data.How to implement a cluster setup cache in my java springboot application?

Thanks in advance.

I would suggest using an external cache like Redis. It's quite fast and you can access it with Spring Data JPA. You just set it up as an @Repository. You'll need spring-boot-starter-data-redis as a dependency. AWS offers it as a service called ElastiCache

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM