0

I am in interested to know if the Hibernate Second-Level caching can be shared between two different Hibernate session running on two different JVM.

I am using Hibernate 3.1 with Ehcache to provide second-level caching, and in the Ehcache.xml config file we can specify where we like to create the cache on the disk

    <ehcache>
        <diskStore path="C:\Learn\db"/>
</ehcache>

So If I now open two different Hibernate session, in different JVMs where both pointing to the same , will that allow me to share the second-level cache between two JVM.

If this is the case. so if one of the Hibernate session update its cache (session level cache), will the subsequently update the second-level cache and hence the second session running on different JVM when access that cache will get the updated data.

many thanks.

2 Answers 2

1

You can use any of the ehcache replication/clustering mechanisms with your Hibernate second level caches. See either:

Now, depending on the which replication/clustering solution you go for, all caching strategies might not be recommended, but at least it wouldn't require a full XA environment.

Sign up to request clarification or add additional context in comments.

1 Comment

first link is down
1

Yes you can, I don't know about ehcache but infinispan allows you to do this (assuming you are sharing a database)

https://docs.jboss.org/author/display/ISPN/Using+Infinispan+as+JPA-Hibernate+Second+Level+Cache+Provider

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.