diff --git a/build.gradle b/build.gradle index b660844369..af034ff5b4 100644 --- a/build.gradle +++ b/build.gradle @@ -77,7 +77,7 @@ task ciBuild { task wrapper(type: Wrapper) { - gradleVersion = '4.4' + gradleVersion = '4.6' distributionType = 'ALL' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 61e0490bbe..9a4163a4f5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/QueryResultRegionAccessImpl.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/QueryResultRegionAccessImpl.java index 54b8692784..7511438b74 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/QueryResultRegionAccessImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/QueryResultRegionAccessImpl.java @@ -93,7 +93,7 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess { try { session.getEventListenerManager().cachePutStart(); - cacheRegion.getStorageAccess().putIntoCache( key, cacheItem ); + cacheRegion.putIntoCache( key, cacheItem ); } finally { session.getEventListenerManager().cachePutEnd(); @@ -189,7 +189,7 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess { CacheItem cachedItem = null; try { session.getEventListenerManager().cacheGetStart(); - cachedItem = (CacheItem) cacheRegion.getStorageAccess().getFromCache( key ); + cachedItem = (CacheItem) cacheRegion.getFromCache( key ); } finally { session.getEventListenerManager().cacheGetEnd( cachedItem != null ); @@ -286,11 +286,6 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess { return "QueryResultsCache(" + cacheRegion.getName() + ')'; } - @Override - public void clear() throws CacheException { - cacheRegion.getStorageAccess().clearCache(); - } - public static class CacheItem implements Serializable { private final long timestamp; private final List results; diff --git a/hibernate-core/src/main/java/org/hibernate/cache/internal/TimestampsRegionAccessEnabledImpl.java b/hibernate-core/src/main/java/org/hibernate/cache/internal/TimestampsRegionAccessEnabledImpl.java index c6258d98f3..4020b54e78 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/internal/TimestampsRegionAccessEnabledImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/internal/TimestampsRegionAccessEnabledImpl.java @@ -9,8 +9,8 @@ package org.hibernate.cache.internal; import java.io.Serializable; import org.hibernate.cache.spi.RegionFactory; -import org.hibernate.cache.spi.TimestampsRegionAccess; import org.hibernate.cache.spi.TimestampsRegion; +import org.hibernate.cache.spi.TimestampsRegionAccess; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; @@ -57,7 +57,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess //put() has nowait semantics, is this really appropriate? //note that it needs to be async replication, never local or sync - timestampsRegion.getStorageAccess().putIntoCache( space, ts ); + timestampsRegion.putIntoCache( space, ts ); } finally { session.getEventListenerManager().cachePutEnd(); @@ -84,7 +84,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess try { session.getEventListenerManager().cachePutStart(); - timestampsRegion.getStorageAccess().putIntoCache( space, ts ); + timestampsRegion.putIntoCache( space, ts ); } finally { session.getEventListenerManager().cachePutEnd(); @@ -135,7 +135,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess Long ts = null; try { session.getEventListenerManager().cacheGetStart(); - ts = (Long) timestampsRegion.getStorageAccess().getFromCache( space ); + ts = (Long) timestampsRegion.getFromCache( space ); } finally { session.getEventListenerManager().cacheGetEnd( ts != null ); diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/DirectAccessRegion.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/DirectAccessRegion.java index 9c173e2c12..8be620ddc6 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/DirectAccessRegion.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/DirectAccessRegion.java @@ -6,25 +6,20 @@ */ package org.hibernate.cache.spi; -import org.hibernate.cache.CacheException; -import org.hibernate.cache.spi.support.StorageAccess; - /** * Specialized Region whose data is accessed directly - not requiring - * key wrapping, e.g. + * key/item wrapping, e.g. * * @author Steve Ebersole */ public interface DirectAccessRegion extends Region { - StorageAccess getStorageAccess(); - - @Override - default void clear() { - getStorageAccess().clearCache(); + default boolean contains(Object key) { + return getFromCache( key ) != null; } - @Override - default void destroy() throws CacheException { - getStorageAccess().release(); - } + Object getFromCache(Object key); + + void putIntoCache(Object key, Object value); + + void removeFromCache(Object key); } diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultRegionAccess.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultRegionAccess.java index 9a5ae4d912..491efe7866 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultRegionAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/QueryResultRegionAccess.java @@ -36,7 +36,7 @@ public interface QueryResultRegionAccess extends QueryCache { */ @Override default void clear() throws CacheException { - getRegion().getStorageAccess().clearCache(); + getRegion().clear(); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/TimestampsRegionAccess.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/TimestampsRegionAccess.java index dead81dc94..e7612c8df9 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/TimestampsRegionAccess.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/TimestampsRegionAccess.java @@ -95,7 +95,7 @@ public interface TimestampsRegionAccess extends UpdateTimestampsCache { @Override default void clear() throws CacheException { - getRegion().getStorageAccess().clearCache(); + getRegion().clear(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/cache/spi/support/DirectAccessRegionTemplate.java b/hibernate-core/src/main/java/org/hibernate/cache/spi/support/DirectAccessRegionTemplate.java index 280fcfa0cc..08aef16d69 100644 --- a/hibernate-core/src/main/java/org/hibernate/cache/spi/support/DirectAccessRegionTemplate.java +++ b/hibernate-core/src/main/java/org/hibernate/cache/spi/support/DirectAccessRegionTemplate.java @@ -16,4 +16,37 @@ public abstract class DirectAccessRegionTemplate extends AbstractRegion implemen public DirectAccessRegionTemplate(String name, RegionFactory regionFactory) { super( name, regionFactory ); } + + public abstract StorageAccess getStorageAccess(); + + @Override + public boolean contains(Object key) { + return getStorageAccess().contains( key ); + } + + @Override + public Object getFromCache(Object key) { + return getStorageAccess().getFromCache( key ); + } + + @Override + public void putIntoCache(Object key, Object value) { + getStorageAccess().putIntoCache( key, value ); + } + + @Override + public void removeFromCache(Object key) { + getStorageAccess().removeFromCache( key ); + } + + @Override + public void clear() { + getStorageAccess().clearCache(); + } + + @Override + public void destroy() { + getStorageAccess().release(); + } + }