public async Task <ExchangeRatesResponse> GetRates(ExchangeRatesRequest request) { if (request is null) { throw new ArgumentNullException(nameof(request)); } var cacheKey = BuildCacheKey(request); var response = _Cache.Get(cacheKey) as ExchangeRatesResponse; if (response is null) { response = await _Access.GetRates(request); _Cache.Add(cacheKey, response, new CacheItemPolicy()); } return(response); }
private string BuildCacheKey(ExchangeRatesRequest request) { var cacheKey = $"{request.BaseCurrency}|{request.Date.ToString("yyyyMMdd", CultureInfo.InvariantCulture)}"; return(cacheKey); }