public async Task <List <SearchResult> > SearchAsync(SearchQuery query) { var result = await cachesrv.getFromCache(query); if (result != null && result.Count > 0) { return(result); } var res = this.apiclient.Search(query); await cachesrv.addToCache(query, new List <SearchResult>(res)).ConfigureAwait(false); return(new List <SearchResult>(res)); }
public List <SearchResult> Search(SearchQuery query) { var task = Task.Run(async() => await cachesrv.getFromCache(query)); if (task.Result != null && task.Result.Count > 0) { return(task.Result); } var res = this.apiclient.Search(query); Task.Run(async() => await cachesrv.addToCache(query, new List <SearchResult>(res))); return(new List <SearchResult>(res)); }