Hibernate version:
2.1.7c
I've read a previous post relating to query caching and the various cache providers
here, but didn't want to revive that old thread. My question relates to Hibernate's query caching mechanism, and in particular, the SwarmCache provider. I've been tracing through the Hibernate source and debugging my application today, and I can't figure out why the query cache doesn't work with the SwarmCache provider. Is it still true that the SwarmCache provider does not support query caching? If so, I'm looking for details as to why that is the case.
After tracing through the Hibernate source, I've determined that StandardQueryCache is used for the default query cache (with a null region) as well as for the named-region query caches. Each StandardQueryCache contains a Cache built from the CacheProvider defined in the settings. In my case, the CacheProvider is a SwarmCacheProvider. Each StandardQueryCache also contains an updateTimestampsCache that also has an underlying SwarmCache implementation (using the same CacheProvider). Since each of the underlying caches in the QueryCache is a SwarmCache, I'm a bit confused as to why the cache invalidations are not working across servers.
For example, when I explicitly evict cached queries for a region via SessionFactory.evictQueries(regionName), this just clears the queryCache for the specified region. Since the underlying implementation is a SwarmCache, I would think that this would evict the queries across servers (via IP multicast/JGroups), no? Similarly, when Hibernate updates the updateTimestampsCache, wouldn't this also work across servers?
The one potential problem that I can see is that Hibernate only ever does puts into the updateTimestampsCache (except when clearing the updateTimestamps cache if there aren't any named cache regions in use for query caching). If you use named cache regions, then Hibernate doesn't do any explicit clears of the updateTimestampsCache. SwarmCache doesn't send out multicast messages notifying of cache puts unless there is already an object in the local cache. Is this one issue the reason that SwarmCache isn't supported by query caching in Hibernate? If that's the case, is there anything that you can think of that we can do to work around this limitation? Have Hibernate developers considered adding query caching support for SwarmCache, or is this limitation an issue they're leaving up to SwarmCache to fix?
I'm just curious what other developers think the best route is to go to address these issues. Thanks in advance for any input you can provide :)
Brian Lenz