类org.hibernate.cache.spi.Region源码实例Demo

下面列出了怎么用org.hibernate.cache.spi.Region的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: lams   文件: StatisticsImpl.java
@Override
public CacheRegionStatisticsImpl getDomainDataRegionStatistics(String regionName) {
	if ( sessionFactory == null ) {
		return null;
	}

	return l2CacheStatsMap.computeIfAbsent(
			regionName,
			s -> {
				final Region region = sessionFactory.getCache().getRegion( regionName );

				if ( region == null ) {
					throw new IllegalArgumentException( "Unknown cache region : " + regionName );
				}

				if ( region instanceof QueryResultsRegion ) {
					throw new IllegalArgumentException(
							"Region name [" + regionName + "] referred to a query result region, not a domain data region"
					);
				}

				return new CacheRegionStatisticsImpl( region );
			}
	);
}
 
源代码2 项目: lams   文件: StatisticsImpl.java
@Override
public CacheRegionStatisticsImpl getCacheRegionStatistics(String regionName) {
	if ( sessionFactory == null ) {
		return null;
	}

	if ( ! sessionFactory.getSessionFactoryOptions().isSecondLevelCacheEnabled() ) {
		return null;
	}

	return l2CacheStatsMap.computeIfAbsent(
			regionName,
			s -> {
				Region region = sessionFactory.getCache().getRegion( regionName );

				if ( region == null ) {
					// this is the pre-5.3 behavior.  and since this is a pre-5.3 method it should behave consistently
					// NOTE that this method is deprecated
					region = sessionFactory.getCache().getQueryResultsCache( regionName ).getRegion();
				}

				return new CacheRegionStatisticsImpl( region );
			}
	);
}
 
@Override
public long getElementCountInMemory() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountInMemory();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
@Override
public long getElementCountOnDisk() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
@Override
public long getSizeInMemory() {
	long count = 0;
	HashSet<Region> processedRegions = null;

	for ( NaturalIdDataAccess accessStrategy : accessStrategies ) {
		final DomainDataRegion region = accessStrategy.getRegion();
		if ( ExtendedStatisticsSupport.class.isInstance( region ) ) {

		}

		if ( region instanceof ExtendedStatisticsSupport ) {
			if ( processedRegions == null ) {
				processedRegions = new HashSet<>();
			}
			if ( processedRegions.add( region ) ) {
				count += ( (ExtendedStatisticsSupport) region ).getElementCountOnDisk();
			}
		}

	}

	if ( count == 0 ) {
		return NO_EXTENDED_STAT_SUPPORT_RETURN;
	}

	return count;
}
 
源代码6 项目: lams   文件: AbstractCacheableDataStatistics.java
public AbstractCacheableDataStatistics(Supplier<Region> regionSupplier) {
	final Region region = regionSupplier.get();
	if ( region == null ) {
		this.cacheRegionName = null;
		this.cacheHitCount = null;
		this.cacheMissCount = null;
		this.cachePutCount = null;
	}
	else {
		this.cacheRegionName = region.getName();
		this.cacheHitCount = new LongAdder();
		this.cacheMissCount = new LongAdder();
		this.cachePutCount = new LongAdder();
	}
}
 
源代码7 项目: lams   文件: EnabledCaching.java
protected QueryResultsRegion makeQueryResultsRegion(String regionName) {
	// make sure there is not an existing domain-data region with that name..
	final Region existing = regionsByName.get( regionName );
	if ( existing != null ) {
		if ( !QueryResultsRegion.class.isInstance( existing ) ) {
			throw new IllegalStateException( "Cannot store both domain-data and query-result-data in the same region [" + regionName );
		}

		throw new IllegalStateException( "Illegal call to create QueryResultsRegion - one already existed" );
	}

	return regionFactory.buildQueryResultsRegion( regionName, getSessionFactory() );
}
 
源代码8 项目: lams   文件: CacheImplementor.java
/**
 * @deprecated No replacement - added just for support of the newly deprecated methods expecting a qualified region name
 */
@Deprecated
default Region getRegionByLegacyName(String legacyName) {
	return getRegion( unqualifyRegionName( legacyName ) );
}
 
源代码9 项目: lams   文件: CacheRegionStatisticsImpl.java
CacheRegionStatisticsImpl(Region region) {
	this.region = region;
}
 
源代码10 项目: lams   文件: DisabledCaching.java
@Override
public Region getRegion(String fullRegionName) {
	return null;
}
 
源代码11 项目: lams   文件: EnabledCaching.java
@Override
public Region getRegion(String regionName) {
	return regionsByName.get( regionName );
}
 
源代码12 项目: lams   文件: EnabledCaching.java
@Override
public void close() {
	for ( Region region : regionsByName.values() ) {
		region.destroy();
	}
}
 
源代码13 项目: lemon   文件: SessionFactoryWrapper.java
public Region getSecondLevelCacheRegion(String regionName) {
    return sessionFactoryImplementor.getSecondLevelCacheRegion(regionName);
}
 
源代码14 项目: lemon   文件: SessionFactoryWrapper.java
public Region getNaturalIdCacheRegion(String regionName) {
    return sessionFactoryImplementor.getNaturalIdCacheRegion(regionName);
}
 
源代码15 项目: lams   文件: CacheImplementor.java
/**
 * Get a cache Region by name
 *
 * @apiNote It is only valid to call this method after {@link #prime} has
 * been performed
 *
 * @since 5.3
 */
Region getRegion(String regionName);
 
 类所在包
 类方法
 同包方法