今天查看hibernate cache接口时 svn了hibernate3.3
![](/icons/19964de.gif)
源码
打开CacheProvider类
![](/icons/19964yi.gif)
看 居然给 @deprecated
真是大块人心
早就对hibernate
![](/icons/19964de.gif)
2级缓存Cache和查询缓存Cache不爽
只能按照实体配置 不能针对某条查询语句设置
3.3
![](/icons/19964de.gif)
提供了两个接口 Region RegionFactory 来代替 3.2中
![](/icons/19964de.gif)
Cache CacheProvider
看看RegionFactory
![](/icons/19964de.gif)
实现吧
看看这几个思路方法名字是多么
![](/icons/19964de.gif)
让人激动
Java代码
buildCollectionRegion 对集合
缓存Cache 猜测是对
对多
集合进行配置
吧
buildQueryResultsRegion 查询缓存Cache 自定义
查询 也可以有自己
region了
buildTimestampsRegion 给缓存Cache设置过期时间吧
英文不好 猜测
![](/icons/19964de.gif)
英文好
![](/icons/19964de.gif)
可以翻译
![](/icons/19964yi.gif)
下
在gg上搜索了
![](/icons/19964yi.gif)
下hibernate RegionFactory 关键字 居然没搜索到
难道大家对个功能都不感冒
Java代码
public
erface RegionFactory {
public void start(Settings
tings, Properties properties) throws CacheException;
public void stop
;
public boolean isMinimalPutsEnabledByDefault
;
public long nextTimestamp
;
public EntityRegion buildEntityRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
public CollectionRegion buildCollectionRegion(String regionName, Properties properties, CacheDataDescription metadata) throws CacheException;
public QueryResultsRegion buildQueryResultsRegion(String regionName, Properties properties) throws CacheException;
public TimestampsRegion buildTimestampsRegion(String regionName, Properties properties) throws CacheException;
}
附上hibernate3.3 cache包里
![](/icons/19964de.gif)
介绍说明
引用
This package
![](/icons/19964define.gif)
s APIs/SPIs and implementations for the Hibernate second-level cache.
The legacy (and now deprecated) approach to caching is
![](/icons/19964define.gif)
d by the {@link org.hibernate.cache.CacheProvider} and {@link org.hibernate.cache.Cache}
![](/icons/19964int.gif)
erfaces as well as the {@link org.hibernate.cache.CacheConcurrencyStrategy}
![](/icons/19964int.gif)
erface along with the various implementations of all these
![](/icons/19964int.gif)
erfaces. In that scheme, a {@link org.hibernate.cache.CacheProvider}
![](/icons/19964define.gif)
d how to configure and perform l
![](/icons/19964if.gif)
ecycle operations in regards to a particular underlying caching library; it also
![](/icons/19964define.gif)
d how to build {@link org.hibernate.cache.Cache} instances which in turn
![](/icons/19964define.gif)
d how to access the "regions" of the underlying cache instance. For entity and collection data cache regions, {@link org.hibernate.cache.CacheConcurrencyStrategy} wrapped access to those cache regions to apply transactional/concurrent access semantics.
The improved approach is based on {@link org.hibernate.cache.RegionFactory}, the various {@link org.hibernate.cache.Region} specializations and the two access strategies contracts ({@link org.hibernate.cache.access.EntityRegionAccessStrategy} and {@link org.hibernate.cache.access.CollectionRegionAccessStrategy}). The general approach here is that {@link org.hibernate.cache.RegionFactory}
![](/icons/19964define.gif)
d how to configure and perform l
![](/icons/19964if.gif)
ecycle operations in regards to a particular underlying caching library (or libraries). {@link org.hibernate.cache.RegionFactory} also
![](/icons/19964define.gif)
s how to build specialized {@link org.hibernate.cache.Region} instances based on the type of data we will be storing in that given region. The fact that {@link org.hibernate.cache.RegionFactory} is asked to build specialized regions (as opposed to just general access) is the first improvement over the legacy scheme. The second improvement is the fact that the regions (well the ones like entity and collection regions that are responsible for storing {@link org.hibernate.cache.TransactionalDataRegion transactional} data) are asked to build their own access strategies (see {@link org.hibernate.cache.EntityRegion#buildAccessStrategy} and {@link org.hibernate.cache.CollectionRegion#buildAccessStrategy}).
延伸阅读
最新评论