开发者

Hibernate Distributed Cache - can multiple applications share same cache?

I'm looking to setup Hibernate with distributed cache where I have one application writing to the DB and another one reading from the DB. Is there an easy way to notify the reading application when the writing one has written through Hibernate? The distributed cache will invalidate the cache but I need the reading application to know a change has been ma开发者_JS百科de to refresh its data immediately.

Thanks, D


Use a replicating cache such as JBossCache,InfiniSpan or EHCache and configure to replicate updates instead of invalidating cache. e.g. http://docs.jboss.org/jbosscache/1.4.0/TreeCache/en/html/replication.html http://ehcache.org/documentation/distributed_caching.html


You're not going to get this working without some effort, I think, although all of the components are there to do the individual bits you need.

Specifically, Hibernate has built-in support for JBossCache 2 as a 2nd-level distributed cache. JBossCache does provide an event architecture which allows you to listen to changes in the cache.

The challenge will be to tie the two together, and figure out how to listen to changes in the JBossCache config that hibernate uses. It should be possible, you'll just have to do a bit of reading.

JBossCache2 is a bit old now, but it's the latest version that Hibernate supports out-of-the-box. There is documentation on the JBossCache website for getting v3 working with Hibernate, but that takes extra work.

Edit: It seems that development of JBossCache is being halted in favour of its replacement, Infinispan. There's documentation on how to integrate that with Hibernate.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜