HHH-13527 Optimise DefaultLoadEventListener#getFromSharedCache hot path

This commit is contained in:
Sanne Grinovero 2019-08-06 09:02:06 +01:00 committed by Sanne Grinovero
parent 3dbf0166fe
commit eb1ab2cd9b

View File

@ -731,23 +731,25 @@ private Object getFromSharedCache(
final EntityPersister persister,
SessionImplementor source ) {
final EntityDataAccess cache = persister.getCacheAccessStrategy();
final SessionFactoryImplementor factory = source.getFactory();
final Object ck = cache.generateCacheKey(
event.getEntityId(),
persister,
source.getFactory(),
factory,
source.getTenantIdentifier()
);
final Object ce = CacheHelper.fromSharedCache( source, ck, persister.getCacheAccessStrategy() );
if ( source.getFactory().getStatistics().isStatisticsEnabled() ) {
final StatisticsImplementor statistics = factory.getStatistics();
if ( statistics.isStatisticsEnabled() ) {
if ( ce == null ) {
source.getFactory().getStatistics().entityCacheMiss(
statistics.entityCacheMiss(
StatsHelper.INSTANCE.getRootEntityRole( persister ),
cache.getRegion().getName()
);
}
else {
source.getFactory().getStatistics().entityCacheHit(
statistics.entityCacheHit(
StatsHelper.INSTANCE.getRootEntityRole( persister ),
cache.getRegion().getName()
);