NHibernate查询缓存过期

Fra*_*ois 4 nhibernate query-cache

是否可以配置NHibernate查询缓存的到期时间?

对于二级缓存我可以做到nhibernate.cfg.xml,但我找不到SQL查询缓存的方法.

编辑:

ICriteria query = CreateCriteria()
                  .Add(Expression.Eq("Email", identifiant))
                  .SetCacheable(true)
                  .SetCacheRegion("X");



 <syscache>
    <cache region="X" expiration="10" priority="1" />
  </syscache>
Run Code Online (Sandbox Code Playgroud)

Rad*_*ler 6

是的,我们可以通过区域设置缓存过期.像这样调整查询:

criteria.SetCacheable(true)
    .SetCacheMode(CacheMode.Normal)
    .SetCacheRegion("LongTerm");
Run Code Online (Sandbox Code Playgroud)

并将类似的配置放入web.config文件中

<configSections>
    <section name="syscache" type="NHibernate.Caches.SysCache.SysCacheSectionHandler, NHibernate.Caches.SysCache" requirePermission="false" />
</configSections>
<syscache>
    <cache region="LongTerm" expiration="180" priority="5" />
    <cache region="ShortTerm" expiration="60" priority="3" />
</syscache>
Run Code Online (Sandbox Code Playgroud)

编辑:我只是添加此链接按标准获取实体时未使用的类高速缓存 确保SQL查询高速缓存的含义.在链接的答案中,我正在解释该主题

只是为了清楚.NHibernate"session-factory"的配置必须包含:

<property name="cache.use_query_cache">true</property>
Run Code Online (Sandbox Code Playgroud)

此开关将使查询缓存工作.更多细节:http://nhibernate.info/doc/nh/en/index.html#performance-querycache