Created
May 21, 2014 20:23
-
-
Save herskinduk/1c22b4d24290f104017f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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