Try our conversational search powered by Generative AI!

FindPagesWithCritera / SearchDataSource and cache

Vote:
 
Does either or both of FindPagesWithCriteria and SearchDataSource cache the results of a query? What I mean is, if i execute the same query twice in a short time and no page changes have been made, will the query still go to the database or not?
#33065
Oct 01, 2009 7:25
Vote:
 

Short answer: No.

Long answer:
FindPagesWithCriteria will do one database request per criteria (and possibly language) you provide to get the a PageReference to every page that matches the query. Then it calls GetPage on datafactory for each reference returned. This will of course be cached, so a second query could be significantly faster than a first one that returns uncached pages.
So to summarize, each page is cached but the query itself isn't.

Cheers
Henrik

#33066
Oct 01, 2009 8:16
Vote:
 

Thanks for the quick reply.

So if I want to speed things up I could cache the result in a key based on the query for example? What should I cache - the PageDataCollection or an array of PageReferences or ID:s? I mean - if I cache the PageDataCollection, will that mean that I duplicate the data cached by DataFactory for each PageData object?

#33067
Oct 01, 2009 8:27
Vote:
 

I would say have a look at the CacheFramework on EPiCode https://www.coderesort.com/p/epicode/wiki/CacheFramework for an implementation.

#33068
Oct 01, 2009 8:36
Vote:
 
I'll check it out, thanks!
#33069
Oct 01, 2009 8:41
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.