HHH-12531 Use short, simple names for the query result and update timestamps caching regions
This commit is contained in:
parent
2649e1372c
commit
63cc63b386
|
@ -316,17 +316,19 @@ Just as with collection caching, the query cache should always be used in conjun
|
|||
|
||||
This setting creates two new cache regions:
|
||||
|
||||
`org.hibernate.cache.internal.StandardQueryCache`::
|
||||
`default-query-results-region`::
|
||||
Holding the cached query results
|
||||
`org.hibernate.cache.spi.UpdateTimestampsCache`::
|
||||
`default-update-timestamps-region`::
|
||||
Holding timestamps of the most recent updates to queryable tables.
|
||||
These are used to validate the results as they are served from the query cache.
|
||||
|
||||
[IMPORTANT]
|
||||
====
|
||||
If you configure your underlying cache implementation to use expiration, it's very important that the timeout of the underlying cache region for the `UpdateTimestampsCache` is set to a higher value than the timeouts of any of the query caches.
|
||||
If you configure your underlying cache implementation to use expiration, it's very important
|
||||
that the timeout of the underlying cache region for the `default-update-timestamps-region`
|
||||
is set to a higher value than the timeouts of any of the query caches.
|
||||
|
||||
In fact, we recommend that the `UpdateTimestampsCache` region is not configured for expiration (time-based) or eviction (size/memory-based) at all.
|
||||
In fact, we recommend that the `default-update-timestamps-region` region is not configured for expiration (time-based) or eviction (size/memory-based) at all.
|
||||
Note that an LRU (Least Recently Used) cache eviction policy is never appropriate for this particular cache region.
|
||||
====
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ public class CacheableNaturalIdTest extends BaseEntityManagerFunctionalTestCase
|
|||
|
||||
@Override
|
||||
public void buildEntityManagerFactory() {
|
||||
JCacheHelper.locateStandardCacheManager().createCache( "org.hibernate.cache.spi.TimestampsRegion", new MutableConfiguration<>() );
|
||||
JCacheHelper.locateStandardCacheManager().createCache( "org.hibernate.cache.spi.QueryResultsRegion", new MutableConfiguration<>() );
|
||||
JCacheHelper.locateStandardCacheManager().createCache( "default-update-timestamps-region", new MutableConfiguration<>() );
|
||||
JCacheHelper.locateStandardCacheManager().createCache( "default-query-results-region", new MutableConfiguration<>() );
|
||||
JCacheHelper.locateStandardCacheManager().createCache( "org.hibernate.userguide.mapping.identifier.CacheableNaturalIdTest$Book##NaturalId", new MutableConfiguration<>() );
|
||||
// JCacheHelper.locateStandardCacheManager().createCache( "", new MutableConfiguration<>() );
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
|
|||
|
||||
if ( getSessionFactory().getSessionFactoryOptions().isQueryCacheEnabled() ) {
|
||||
final TimestampsRegion timestampsRegion = regionFactory.buildTimestampsRegion(
|
||||
TimestampsRegion.class.getName(),
|
||||
RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME,
|
||||
sessionFactory
|
||||
);
|
||||
timestampsCache = sessionFactory.getSessionFactoryOptions()
|
||||
|
@ -87,7 +87,7 @@ public class EnabledCaching implements CacheImplementor, DomainDataRegionBuildin
|
|||
legacySecondLevelCacheNames.add( timestampsRegion.getName() );
|
||||
|
||||
final QueryResultsRegion queryResultsRegion = regionFactory.buildQueryResultsRegion(
|
||||
QueryResultsRegion.class.getName(),
|
||||
RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME,
|
||||
sessionFactory
|
||||
);
|
||||
regionsByName.put( queryResultsRegion.getName(), queryResultsRegion );
|
||||
|
|
|
@ -31,6 +31,11 @@ import org.hibernate.service.spi.Stoppable;
|
|||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface RegionFactory extends Service, Stoppable {
|
||||
|
||||
// These are names that users have to include in their caching configuration, do not change them
|
||||
String DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME = "default-query-results-region";
|
||||
String DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME = "default-update-timestamps-region";
|
||||
|
||||
/**
|
||||
* Lifecycle callback to perform any necessary initialization of the
|
||||
* underlying cache provider. Called exactly once during the
|
||||
|
|
|
@ -10,7 +10,6 @@ import java.util.Arrays;
|
|||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Stream;
|
||||
import javax.cache.Cache;
|
||||
import javax.cache.CacheManager;
|
||||
|
@ -21,11 +20,9 @@ import org.hibernate.boot.MetadataSources;
|
|||
import org.hibernate.boot.registry.StandardServiceRegistry;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cache.jcache.JCacheHelper;
|
||||
import org.hibernate.cache.spi.QueryResultsRegion;
|
||||
import org.hibernate.cache.spi.TimestampsRegion;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.cache.spi.support.RegionNameQualifier;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.H2Dialect;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
|
@ -70,8 +67,8 @@ public class TestHelper {
|
|||
createCache( cacheManager, regionName, prefixCaches );
|
||||
}
|
||||
|
||||
createCache( cacheManager, TimestampsRegion.class.getName(), prefixCaches );
|
||||
createCache( cacheManager, QueryResultsRegion.class.getName(), prefixCaches );
|
||||
createCache( cacheManager, RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, prefixCaches );
|
||||
createCache( cacheManager, RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, prefixCaches );
|
||||
}
|
||||
|
||||
public static SessionFactoryImplementor buildStandardSessionFactory() {
|
||||
|
@ -187,8 +184,8 @@ public class TestHelper {
|
|||
}
|
||||
|
||||
if ( queryRegions ) {
|
||||
createCache( cacheManager, TimestampsRegion.class.getName(), prefixRegions );
|
||||
createCache( cacheManager, QueryResultsRegion.class.getName(), prefixRegions );
|
||||
createCache( cacheManager, RegionFactory.DEFAULT_UPDATE_TIMESTAMPS_REGION_UNQUALIFIED_NAME, prefixRegions );
|
||||
createCache( cacheManager, RegionFactory.DEFAULT_QUERY_RESULTS_REGION_UNQUALIFIED_NAME, prefixRegions );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue