Skip to content

Instantly share code, notes, and snippets.

@herskinduk
Created May 21, 2014 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herskinduk/1c22b4d24290f104017f to your computer and use it in GitHub Desktop.
Save herskinduk/1c22b4d24290f104017f to your computer and use it in GitHub Desktop.
public class LazySearchService : ISearchService
{
public readonly ISearchService innerService;
public LazySearchService(ISearchService innerService)
{
this.innerService = innerService;
}
public ISearchResult Search(SearchCriteria criteria)
{
var hash = criteria.GetHashCode().ToString();
if (!Sitecore.Context.Items.Contains(hash))
{
Sitecore.Context.Items.Add(hash, innerService.Search(criteria));
}
return Sitecore.Context.Items[hash] as ISearchResult;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment