Ejemplo n.º 1
0
        public async Task <IEnumerable <Exercise> > GetExercises([FromQuery] ExerciseParams exerciseParams)
        {
            string key = $"exercises-{exerciseParams.PageNumber}-{exerciseParams.ItemsPerPage}-{exerciseParams.Name}";

            if (!_memoryCache.TryGetValue(key, out PagedList <Exercise> exercises))
            {
                exercises = await _exerciseService.FindExercisesAsync(exerciseParams);

                _memoryCache.Set(key, exercises, TimeSpan.FromMinutes(2));
            }

            Response.AddPaginationHeader(exercises.TotalItems, exercises.ItemsPerPage, exercises.PageNumber,
                                         exercises.TotalPages);
            return(exercises);
        }