Question

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,...)

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top