Search code examples
javahibernatespring-bootinfinispan

Can the infinispan cache be shared among multiple instances of the same spring boot application using hibernate?


I have a spring boot application which uses hibernate. I want to run multiple instances of this application which connects to the same database. I accidentally stumbled on infinispan as a second-level cache. I would like to implement infinispan as a second-level cache for hibernate. Now if I start multiple instances of this same spring boot application, will the infinispan caches of all the different instances be shared among each other?


Solution

  • The default Infinispan configuration in use with Hibernate 2nd level cache would result on each instance trying to find each other. For this to work, they'd need to find each other via UDP multicast, and then they would communicate with each other via TCP.

    We have an Spring Boot Hibernate Cache example that uses Infinispan that overrides this configuration for using it with a single instance.

    If you comment this line, Infinispan would use the clustered configuration.