Exemplo n.º 1
0
        public async Task <IActionResult> Get(string name)
        {
            var exams = _cache.Get <IEnumerable <ExamDto> >("exams");

            if (exams == null)
            {
                Console.WriteLine("Fetching from service.");
                exams = await _examService.BrowseAsync(name);

                _cache.Set("exams", exams, TimeSpan.FromMinutes(1));
            }
            else
            {
                Console.WriteLine("Fetching from cache.");
            }

            return(Json(exams));
        }