Caching in SearchDataSource | Episerver Developer Community

Caching in SearchDataSource

Member since: 2008
 

I might have missed something obvious here, but... 

I have a page with a SearchDataSource which finds pages by keywords. I hook into the Sort event and do some sorting depending on the current sort order selected by the user. When the user changes the sort order I re-bind the SearchDataSource and do the filtering in the event accordingly. I can't use the property sort because I have special requirements on the sorting so I have to do it myself.

Can I somehow get the SearchDataSource to cache the results and just fire the Sort event again (or something else that enables me to sort the collection contained in the SearchDataSource)? Now it seems to do the whole search every time i bind it, even though the search query is the same. That makes sense (it might hit new pages), but it makes everything painfully slow for me. What I would like to do is to keep the search collection in cache, viewstate or whatever while the user fiddles with the sorting, and to execute the search only if the user clicks the search button.

#30200 Jun 05, 2009 15:43
  • Member since: 2008
     
    I worked around this by calling the Select method of the SearchDataSource to get the colleciton, then I can bind it manually to my repeater instead of using DataSourceID. Since I have the collection I can also cache it in Session, ViewState etc.
    #30211 Jun 07, 2009 10:50