下面列出了org.hibernate.cfg.Settings#getCacheRegionPrefix ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public StandardQueryCache(
final Settings settings,
final Properties props,
final UpdateTimestampsCache updateTimestampsCache,
String regionName) throws HibernateException {
if ( regionName == null ) {
regionName = StandardQueryCache.class.getName();
}
String prefix = settings.getCacheRegionPrefix();
if ( prefix != null ) {
regionName = prefix + '.' + regionName;
}
log.info( "starting query cache at region: " + regionName );
this.queryCache = settings.getCacheProvider().buildCache(regionName, props);
this.updateTimestampsCache = updateTimestampsCache;
this.regionName = regionName;
}
public static CacheConcurrencyStrategy createCache(
final String concurrencyStrategy,
String regionName,
final boolean mutable,
final Settings settings,
final Properties properties)
throws HibernateException {
if ( concurrencyStrategy==null || !settings.isSecondLevelCacheEnabled() ) return null; //no cache
String prefix = settings.getCacheRegionPrefix();
if ( prefix!=null ) regionName = prefix + '.' + regionName;
if ( log.isDebugEnabled() ) log.debug("instantiating cache region: " + regionName + " usage strategy: " + concurrencyStrategy);
final CacheConcurrencyStrategy ccs;
if ( concurrencyStrategy.equals(READ_ONLY) ) {
if (mutable) log.warn( "read-only cache configured for mutable class: " + regionName );
ccs = new ReadOnlyCache();
}
else if ( concurrencyStrategy.equals(READ_WRITE) ) {
ccs = new ReadWriteCache();
}
else if ( concurrencyStrategy.equals(NONSTRICT_READ_WRITE) ) {
ccs = new NonstrictReadWriteCache();
}
else if ( concurrencyStrategy.equals(TRANSACTIONAL) ) {
ccs = new TransactionalCache();
}
else {
throw new MappingException("cache usage attribute should be read-write, read-only, nonstrict-read-write or transactional");
}
final Cache impl;
try {
impl = settings.getCacheProvider().buildCache(regionName, properties);
}
catch (CacheException e) {
throw new HibernateException( "Could not instantiate cache implementation", e );
}
ccs.setCache(impl);
return ccs;
}
public UpdateTimestampsCache(Settings settings, Properties props) throws HibernateException {
String prefix = settings.getCacheRegionPrefix();
regionName = prefix == null ? REGION_NAME : prefix + '.' + REGION_NAME;
log.info( "starting update timestamps cache at region: " + regionName );
this.updateTimestamps = settings.getCacheProvider().buildCache( regionName, props );
}