/// <summary> /// Retrieve cache asynchronously /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key"></param> public T GetCache <T, T2>(T2 key) { //Check memory cache first T memoryValue = _memoryCachingManager.GetCache <T, T2>(key); if (memoryValue != null) { return(memoryValue); } //If memory cache null, check distributedCache T distributedValue = _distributedCacheManager.GetCache <T, T2>(key); //If values available in distributed cache but not memory cache, update memory cache if (distributedValue != null) { _memoryCachingManager.SetCache(distributedValue, key); } return(distributedValue); }
private async Task <string> GetResultsFromAPI(string queryString) { //Use the query string as a key so if query is the same we don't have to make an API call. return(_cachingManager.GetCache <string>(queryString) ?? _cachingManager.SetCache(await client.GetStringAsync(queryString), queryString)); }