コード例 #1
0
        public ActionResult <string> Get(string source, string destination, DateTime date)
        {
            var key = source + destination + date.Date.ToShortDateString();

            var cacheResult = _redisDB.StringGet(key);

            if (!cacheResult.HasValue)
            {
                var result = _flightsRepository.GetFlightByDate(source, destination, date);
                if (result == null)
                {
                    return(NotFound());
                }
                _redisDB.StringSet(key, JsonConvert.SerializeObject(result));
                return(Ok(result));
            }
            Request.HttpContext.Response.Headers.Add("X-Cache", "true");
            return(Ok(cacheResult.ToString()));
        }
コード例 #2
0
        public ActionResult <string> Get(string source, string destination, DateTime date)
        {
            var result = _flightsRepository.GetFlightByDate(source, destination, date);

            return(Ok(result));
        }