Search code examples
hibernateinfinispanjboss-eap-6hibernate-cachehot-rod

shared infinispan 2LC cache


I have two applications using same database entities. Both applications are deployed on jboss eap 6.2 separate clusters. DB tables are updated only from one application but are read from both applications. Both applications are using native hibernate APIs to read/write data from database.

After enabling infinispan as 2LC in embedded mode, how do I ensure that cache entities updated in one application are invalidated from 2nd application cache? Any JMX/JMS interface to signal cache invalidation?

If I go for remote cache mode and start infinispan as hot rod server, then cache server can be shared with both application. But then do i need to update code to query entities from cache using hot rod client API's? Also will it update/invalidate the cache automatically if entity is updated from application.


Solution

  • This is not supported. There's no remote second level cache Infinispan implementation for Hibernate. The embedded implementation uses deep integrations with embedded-only features and hence it's not interchangeable.

    If using embedded, each application gets their own caches and these cannot be shared because each application is a separate classloader. So, entity A from classloader X cannot be read with entity A from classloader Y.

    If you really want a shared cache, nothing stops you from doing it yourself, by adding data to a remote Infinispan Server.