public async Task <IActionResult> GetByIp(DateTimeOffset?date) { var ip = HttpContext.Connection.RemoteIpAddress; var cacheKey = $"{ip},{date}"; var cachedSolarTimes = await _cachingLayer.TryGetAsync <SolarTimes>(cacheKey); if (cachedSolarTimes != null) { return(Ok(cachedSolarTimes)); } var location = await _locationProvider.GetLocationAsync(ip); var solarTimes = _solarCalculator.GetSolarTimes(location, date ?? DateTimeOffset.Now); await _cachingLayer.SetAsync(cacheKey, solarTimes); return(Ok(solarTimes)); }