|
|
|
@ -21,9 +21,12 @@ import java.io.InputStream;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.Properties;
|
|
|
|
|
|
|
|
|
|
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
|
|
|
|
import org.hibernate.boot.spi.SessionFactoryOptions;
|
|
|
|
|
import org.hibernate.cache.CacheException;
|
|
|
|
|
import org.hibernate.cache.internal.DefaultCacheKeysFactory;
|
|
|
|
|
import org.hibernate.cache.spi.CacheDataDescription;
|
|
|
|
|
import org.hibernate.cache.spi.CacheKeysFactory;
|
|
|
|
|
import org.hibernate.cache.spi.CollectionRegion;
|
|
|
|
|
import org.hibernate.cache.spi.EntityRegion;
|
|
|
|
|
import org.hibernate.cache.spi.NaturalIdRegion;
|
|
|
|
@ -31,6 +34,7 @@ import org.hibernate.cache.spi.QueryResultsRegion;
|
|
|
|
|
import org.hibernate.cache.spi.RegionFactory;
|
|
|
|
|
import org.hibernate.cache.spi.TimestampsRegion;
|
|
|
|
|
import org.hibernate.cache.spi.access.AccessType;
|
|
|
|
|
import org.hibernate.cfg.Environment;
|
|
|
|
|
import org.hibernate.cfg.Settings;
|
|
|
|
|
import org.hibernate.internal.util.config.ConfigurationHelper;
|
|
|
|
|
import org.jboss.logging.Logger;
|
|
|
|
@ -81,11 +85,16 @@ public class RedissonRegionFactory implements RegionFactory {
|
|
|
|
|
|
|
|
|
|
protected RedissonClient redisson;
|
|
|
|
|
private Settings settings;
|
|
|
|
|
private CacheKeysFactory cacheKeysFactory;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void start(SessionFactoryOptions settings, Properties properties) throws CacheException {
|
|
|
|
|
this.redisson = createRedissonClient(properties);
|
|
|
|
|
this.settings = new Settings(settings);
|
|
|
|
|
|
|
|
|
|
StrategySelector selector = settings.getServiceRegistry().getService(StrategySelector.class);
|
|
|
|
|
cacheKeysFactory = selector.resolveDefaultableStrategy(CacheKeysFactory.class,
|
|
|
|
|
properties.get(Environment.CACHE_KEYS_FACTORY), DefaultCacheKeysFactory.INSTANCE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected RedissonClient createRedissonClient(Properties properties) {
|
|
|
|
@ -176,7 +185,7 @@ public class RedissonRegionFactory implements RegionFactory {
|
|
|
|
|
log.debug("Building entity cache region: " + regionName);
|
|
|
|
|
|
|
|
|
|
RMapCache<Object, Object> mapCache = getCache(regionName, properties, ENTITY_DEF);
|
|
|
|
|
return new RedissonEntityRegion(mapCache, this, metadata, settings, properties, ENTITY_DEF);
|
|
|
|
|
return new RedissonEntityRegion(mapCache, this, metadata, settings, properties, ENTITY_DEF, cacheKeysFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -185,7 +194,7 @@ public class RedissonRegionFactory implements RegionFactory {
|
|
|
|
|
log.debug("Building naturalId cache region: " + regionName);
|
|
|
|
|
|
|
|
|
|
RMapCache<Object, Object> mapCache = getCache(regionName, properties, NATURAL_ID_DEF);
|
|
|
|
|
return new RedissonNaturalIdRegion(mapCache, this, metadata, settings, properties, NATURAL_ID_DEF);
|
|
|
|
|
return new RedissonNaturalIdRegion(mapCache, this, metadata, settings, properties, NATURAL_ID_DEF, cacheKeysFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -194,7 +203,7 @@ public class RedissonRegionFactory implements RegionFactory {
|
|
|
|
|
log.debug("Building collection cache region: " + regionName);
|
|
|
|
|
|
|
|
|
|
RMapCache<Object, Object> mapCache = getCache(regionName, properties, COLLECTION_DEF);
|
|
|
|
|
return new RedissonCollectionRegion(mapCache, this, metadata, settings, properties, COLLECTION_DEF);
|
|
|
|
|
return new RedissonCollectionRegion(mapCache, this, metadata, settings, properties, COLLECTION_DEF, cacheKeysFactory);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|