Package org.hibernate.cache.spi

Defines the integration aspect of Hibernate's second-level caching, allowing a "caching backend" to be plugged in as a cache provider.

RegionFactory is the main integration contract that defines how Hibernate interacts with the provider. Its main contract is the generation of Region references with some requested intent (what will be stored there).

A provider will integrate with Hibernate by implementing either:

  1. the contracts in org.hibernate.cache.spi,
  2. the contracts in org.hibernate.cache.spi.support, or
  3. a mix of the above.
The first approach allows for more control over the setup, but also requires more work. The second approach minimizes the work needed to integrate with a cache provider: the integrator is only required to implement the contracts StorageAccess and DomainDataStorageAccess, which are basic read/write abstractions of the underlying cache. That is to say, org.hibernate.cache.spi.support comes with a nearly complete implementation, except for these "storage access" objects.

Alternatively, providers may integrate with Hibernate via Hibernate's support for JCache, which is defined by the hibernate-jcache module. No custom code is necessary, just an implementation of JCache, properly registered via the JCache spec.