Krish
Krish

Reputation: 2002

how to enable cache across spring boot app instances of same service?

We would like to enable caching in spring boot app. I have followed and enabled it using following link:

https://howtodoinjava.com/spring-boot2/spring-boot-cache-example/

when I ran the spring boot app as multiple instances (on different ports like 8081, 8082, ...), its creating each cache for each instance whenever its turn came.

how to enable cache across spring boot app instances ?

Upvotes: 1

Views: 2628

Answers (1)

Divanshu Aggarwal
Divanshu Aggarwal

Reputation: 446

You can't. Each time you run the application, new server starts which maintains its own memory cache.

If you want a common cache, install a separate server, such as Redis, in your system and configure spring app with that. Then, it can be commonly accessed for all instances.

Upvotes: 1

Related Questions