I just recently tried several configurations using several different cache solutions for a clustered cache. I found the JBoss TreeCache to be overkill at best and challengingly complex at worst. Fully transactional replicated caching may well be too much for many scenarios where simple distributed cache invalidation is all that is required. Unfortunately JBoss TreeCache does not support that. SwarmCache seems to be a dead product and the Hibernate documentation clearly states that OSCache cannot be used in a clustered environment.
What to do. What to do.
Well, to make a long story short, thanks to the work of several other developers, OSCache seems to be a viable clustered alternative, though it does not support distributed transactions. Basically, here's what you can do:
1) Get a 2.1 version of OSCache (at version RC1 as of this post) . You can download it from the Java.net site:
https://oscache.dev.java.net/servlets/P ... cumentList
2) Modify the OSCache and OSCacheProvider in Hibernate to take advantage of OSCache's architecture. Basically the current OSCache implementation uses a single OSCache GeneralCacheAdministrator for every Hibernate cache region. This will cause out of memory errors among other things when using it clustered. You need to use a single GeneralCacheAdministrator for the entire cache, and then use an OSCache "group" for each region. There are code fragements available on the web and in the OSCache mailing lists.
3) Use your new provider and cache in your Hibernate configuration.
We're currently performing load testing on the customized cluster, so I don't know that everything will work perfectly yet, but it looks very promising so far.