Gavin,
Following your recommendation, we reviewed SwarmCache + Hibernate pair and did some tests on it. We had couple of minor problems.
1. The original version of SwarmCache had problems shutting down Javagroups communication thread, as well as the Timer cache "garbage collector" thread which is responsible for the removal of the timed-out items from a cache. A destroy() method was added to the caches (currently only LRU and Timer cache implement this method. Others throw java.lang.UnsupportedOperationException) and Hibernate's cache provider for SwarmCache was changed to use this method.
2. SwarmCache was not configuring Timer cache from swarmcache.properties file. It was also fixed
After item 1 was successfully completed, thread shutdown problem disappeared. The only inconvenience remaining is that SessionFactory needs to be explicitly closed (using close() method) to destroy QueryCache, which also uses SwarmCache. This operation finalizes all the threads and lets application be completed successfully.
Overall, the bundle performed much better than JCS, that we were using before. JCS has some real serious issues :) Several to name: 1) Memory leaks 2) Remote Caching not working 3) Clustered deployment support not completely developed. So, it was a very good move, for us, to switch to SwarmCache in Hibernate. Thank you for your guidance.
You can find the fixed bundle at the following address, in case you are interested:
http://www.digijava.org/swarmcache.zip
We were, also, glad to find the new QueryCache feature in Hibernate 2.1. This was something long awaited for, by us. We did some tests - works fine. We have a suggestion there, from our practical experience of business needs, though, if you do not mind.
Some modules in our system operate with the objects of a significant size, so the only efficient way to query data is to use the Scalar Queries. We know that Hibernate also supports caching of Scalar Queries but unfortunately, the results, all go to one cache - QueryCache (compared to Hibernate-persisted objects query, where there's separate query for each class). This is a significant problem for us, and we believe, will be for other users too, because - not all the queries are to have the same cache properties like timeout, max number of objects, max cache size etc. Shortly, we believe, more granularity, in Scalar Query caching, is essential for any mid-to-large size application. We would like to add this feature to Hibernate, but were wondering if you have also thought of it, already, and would point us to some particular direction.
Mikheil, from my team, is working on the implementation of the feature. He is almost through it, doing some tests, and we will share the code as soon as we are finished, of course, but I wanted to share our thinking first, so that if you have some feedback, we can incorporate it into the code now. The way we approach the problem is - we introduce the ability of associating any HQL Scalar Query with a named cache. This will give us both better granularity and the ability to "group" some query results together. The implementation is intended to be backwards-compatible to current, single-cache solution in Hibernate, too. What's your take on this?
thank you