简体   繁体   中英

How to use 2nd Level Cache with NHibernate.Search

How to use 2nd Level Cache with NHibernate.Search ?

I tried to enable SetCacheable on FullTextQuery, but it doesn't work.

        var session = Search.CreateFullTextSession(database.Session);

        session.CacheMode = CacheMode.Normal;

        var textQuery = session.CreateFullTextQuery(query, new[] { typeof(Job) });

        textQuery.SetCacheable(true);
        textQuery.SetCacheRegion("Job");

        var jobs = textQuery.List<Job>();

        return jobs;

For all other standard queries tha cache works well but with FullTextQueries, it doesn't, NHibernate.Search still hit my database.

Note that NHibernate.Search produced queries are SELECT ... WHERE EntityId IN (Id1,Id2,Id3,...)

are you sure that your entities are in the 2nd level cache. Normally you have to be working and querying within transactions in order for the 2nd level cache to do anything.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM