Hibernate 缓存策略

来源:互联网 发布:置乱 数据 算法 编辑:程序博客网 时间:2024/06/05 20:18

转载自:http://docs.jboss.org/hibernate/orm/4.2/devguide/en-US/html_single

 

 

6.2.2. Caching strategies

 

read-only

A read-only cache is good for data that needs to be read often but not modified. It is simple, performs well, and is safe to use in a clustered environment.

nonstrict read-write

Some applications only rarely need to modify data. This is the case if two transactions are unlikely to try to update the same item simultaneously. In this case, you do not need strict transaction isolation, and a nonstrict-read-write cache might be appropriate. If the cache is used in a JTA environment, you must specify hibernate.transaction.manager_lookup_class. In other environments, ensore that the transaction is complete before you call Session.close() or Session.disconnect().

read-write

A read-write cache is appropriate for an application which needs to update data regularly. Do not use a read-write strategy if you need serializable transaction isolation. In a JTA environment, specify a strategy for obtaining the JTA TransactionManager by setting the propertyhibernate.transaction.manager_lookup_class. In non-JTA environments, be sure the transaction is complete before you call Session.close() or Session.disconnect().

                           

transactional

The transactional cache strategy provides support for transactional cache providers such as JBoss TreeCache. You can only use such a cache in a JTA environment, and you must first specifyhibernate.transaction.manager_lookup_class.

 

6.2.3. Second-level cache providers for Hibernate

 

CacheInterfaceSupported strategies  HashTable (testing only) 
  • read-only

  • nontrict read-write

  • read-write

  EHCache 
  • read-only

  • nontrict read-write

  • read-write

  OSCache 
  • read-only

  • nontrict read-write

  • read-write

  SwarmCache 
  • read-only

  • nontrict read-write

  JBoss Cache 1.x 
  • read-only

  • transactional

  JBoss Cache 2.x 
  • read-only

  • transactional

  
原创粉丝点击