NHibernate 二级缓冲
session.CreateCriteria(typeof(SysModuleFields)).SetCacheable(true).List<SysModuleFields>();
session是ISession
----------------
FluentNHibernate 的map
public class SysModuleFieldsMap: ClassMap<SysModuleFields>
{
SysModuleFieldsMap()
{
this.Table("Sys_SysModuleFieldsMap");
this.Cache.ReadWrite();
this.Cache.Region("LongTerm");
Id(o => o.Id).Column("Id").GeneratedBy.Guid();
}
}
-----------
config
<session-factory>
<property name="connection.connection_string_name">DefaultConnection</property>
<property name="connection.isolation">ReadCommitted</property>
<property name="query.substitutions">true 1, false 0, yes 1, no 0</property>
<property name="show_sql">true</property>
<property name="dialect">NHibernate.Dialect.MsSql2008Dialect</property>
<property name="command_timeout">200</property>
<!--1.配置二级缓存提供程序-->
<property name="cache.provider_class">NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache</property>
<!--2.显式启用二级缓存-->
<property name="cache.use_second_level_cache">true</property>
<!--4.启动查询缓存(注:下一篇内容:http://lyj.cnblogs.com)-->
<property name="cache.use_query_cache">true</property>
</session-factory>