HHH-11356 - Adjust the 2nd-Cache SPIs to better reflect supported uses
Fix-ups from Radim's review
This commit is contained in:
parent
93d9162243
commit
fbe32f162a
|
@ -77,7 +77,7 @@ task ciBuild {
|
||||||
|
|
||||||
|
|
||||||
task wrapper(type: Wrapper) {
|
task wrapper(type: Wrapper) {
|
||||||
gradleVersion = '4.4'
|
gradleVersion = '4.6'
|
||||||
distributionType = 'ALL'
|
distributionType = 'ALL'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
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
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|
|
@ -93,7 +93,7 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
session.getEventListenerManager().cachePutStart();
|
session.getEventListenerManager().cachePutStart();
|
||||||
cacheRegion.getStorageAccess().putIntoCache( key, cacheItem );
|
cacheRegion.putIntoCache( key, cacheItem );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
session.getEventListenerManager().cachePutEnd();
|
session.getEventListenerManager().cachePutEnd();
|
||||||
|
@ -189,7 +189,7 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess {
|
||||||
CacheItem cachedItem = null;
|
CacheItem cachedItem = null;
|
||||||
try {
|
try {
|
||||||
session.getEventListenerManager().cacheGetStart();
|
session.getEventListenerManager().cacheGetStart();
|
||||||
cachedItem = (CacheItem) cacheRegion.getStorageAccess().getFromCache( key );
|
cachedItem = (CacheItem) cacheRegion.getFromCache( key );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
session.getEventListenerManager().cacheGetEnd( cachedItem != null );
|
session.getEventListenerManager().cacheGetEnd( cachedItem != null );
|
||||||
|
@ -286,11 +286,6 @@ public class QueryResultRegionAccessImpl implements QueryResultRegionAccess {
|
||||||
return "QueryResultsCache(" + cacheRegion.getName() + ')';
|
return "QueryResultsCache(" + cacheRegion.getName() + ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void clear() throws CacheException {
|
|
||||||
cacheRegion.getStorageAccess().clearCache();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class CacheItem implements Serializable {
|
public static class CacheItem implements Serializable {
|
||||||
private final long timestamp;
|
private final long timestamp;
|
||||||
private final List results;
|
private final List results;
|
||||||
|
|
|
@ -9,8 +9,8 @@ package org.hibernate.cache.internal;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import org.hibernate.cache.spi.RegionFactory;
|
import org.hibernate.cache.spi.RegionFactory;
|
||||||
import org.hibernate.cache.spi.TimestampsRegionAccess;
|
|
||||||
import org.hibernate.cache.spi.TimestampsRegion;
|
import org.hibernate.cache.spi.TimestampsRegion;
|
||||||
|
import org.hibernate.cache.spi.TimestampsRegionAccess;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess
|
||||||
|
|
||||||
//put() has nowait semantics, is this really appropriate?
|
//put() has nowait semantics, is this really appropriate?
|
||||||
//note that it needs to be async replication, never local or sync
|
//note that it needs to be async replication, never local or sync
|
||||||
timestampsRegion.getStorageAccess().putIntoCache( space, ts );
|
timestampsRegion.putIntoCache( space, ts );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
session.getEventListenerManager().cachePutEnd();
|
session.getEventListenerManager().cachePutEnd();
|
||||||
|
@ -84,7 +84,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess
|
||||||
|
|
||||||
try {
|
try {
|
||||||
session.getEventListenerManager().cachePutStart();
|
session.getEventListenerManager().cachePutStart();
|
||||||
timestampsRegion.getStorageAccess().putIntoCache( space, ts );
|
timestampsRegion.putIntoCache( space, ts );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
session.getEventListenerManager().cachePutEnd();
|
session.getEventListenerManager().cachePutEnd();
|
||||||
|
@ -135,7 +135,7 @@ public class TimestampsRegionAccessEnabledImpl implements TimestampsRegionAccess
|
||||||
Long ts = null;
|
Long ts = null;
|
||||||
try {
|
try {
|
||||||
session.getEventListenerManager().cacheGetStart();
|
session.getEventListenerManager().cacheGetStart();
|
||||||
ts = (Long) timestampsRegion.getStorageAccess().getFromCache( space );
|
ts = (Long) timestampsRegion.getFromCache( space );
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
session.getEventListenerManager().cacheGetEnd( ts != null );
|
session.getEventListenerManager().cacheGetEnd( ts != null );
|
||||||
|
|
|
@ -6,25 +6,20 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.cache.spi;
|
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
|
* Specialized Region whose data is accessed directly - not requiring
|
||||||
* key wrapping, e.g.
|
* key/item wrapping, e.g.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface DirectAccessRegion extends Region {
|
public interface DirectAccessRegion extends Region {
|
||||||
StorageAccess getStorageAccess();
|
default boolean contains(Object key) {
|
||||||
|
return getFromCache( key ) != null;
|
||||||
@Override
|
|
||||||
default void clear() {
|
|
||||||
getStorageAccess().clearCache();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
Object getFromCache(Object key);
|
||||||
default void destroy() throws CacheException {
|
|
||||||
getStorageAccess().release();
|
void putIntoCache(Object key, Object value);
|
||||||
}
|
|
||||||
|
void removeFromCache(Object key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public interface QueryResultRegionAccess extends QueryCache {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
default void clear() throws CacheException {
|
default void clear() throws CacheException {
|
||||||
getRegion().getStorageAccess().clearCache();
|
getRegion().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -95,7 +95,7 @@ public interface TimestampsRegionAccess extends UpdateTimestampsCache {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void clear() throws CacheException {
|
default void clear() throws CacheException {
|
||||||
getRegion().getStorageAccess().clearCache();
|
getRegion().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -16,4 +16,37 @@ public abstract class DirectAccessRegionTemplate extends AbstractRegion implemen
|
||||||
public DirectAccessRegionTemplate(String name, RegionFactory regionFactory) {
|
public DirectAccessRegionTemplate(String name, RegionFactory regionFactory) {
|
||||||
super( name, 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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue