JBoss Cache is a tree-structured, clustered, transactional cache. It includes support for maintaining cache consistency across multiple cache instances running in a cluster. It integrates with JTA transaction managers, supporting transaction-scoped locking of cache elements and automatic rollback of cache changes upon transaction rollback. It supports both pessimistic and optimistic locking, with the tree-structure of the cache allowing maximum concurrency.
All of these features make JBoss Cache an excellent choice for use as a
Hibernate Second Level Cache, particularly in
a clustered environment. A Hibernate Session
is a
transaction-scoped cache of persistent data -- data accessed via the
Session
is cached in the Session
for the duration of the current transaction, and then is cleared. A
Second Level Cache is an optional cluster or
JVM-level cache whose contents are maintained beyond the life of a
transaction and whose contents can be shared across transactions.
Use of a Second Level Cache is configured as part of the configuration
of the Hibernate SessionFactory
. If a Second Level
Cache is enabled, caching of an instance of a particular
entity class or of results of a particular query can be configured on
a class-by-class, collection-by-collection and query-by-query basis.
See the Hibernate Reference Documentation for more
on Second Level Cache basics and how to configure entity classes,
collections and queries for caching.
The JBoss Cache Second Level Cache integration supports the
transactional
and read only
cache concurrency strategies discussed in the
Hibernate Reference Documentation. It supports
query caching and is, of course, cluster safe.