NHibernate Request Cache Expiration

Can I configure NHibernate request cache expiration?

For the second level cache, I can do this with nhibernate.cfg.xml , but I cannot find a way to cache SQL queries.

EDIT:

 ICriteria query = CreateCriteria() .Add(Expression.Eq("Email", identifiant)) .SetCacheable(true) .SetCacheRegion("X"); <syscache> <cache region="X" expiration="10" priority="1" /> </syscache> 
+4
source share
1 answer

Yes, we can set the validity period of the cache through the region. Adjust the query as follows:

 criteria.SetCacheable(true) .SetCacheMode(CacheMode.Normal) .SetCacheRegion("LongTerm"); 

And add a similar configuration to the web.config file

 <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> 

EDIT : I just add this link Cache class that is not used when retrieving an object by criteria Of course, I mean the SQL Query cache. In a related answer, I explain that the topic

Just for clarity. The NHibernate "session-factory" configuration should contain:

 <property name="cache.use_query_cache">true</property> 

This switch will make the query cache work. More details: http://nhibernate.info/doc/nh/en/index.html#performance-querycache

+6
source

Source: https://habr.com/ru/post/1443054/


All Articles