Example #1
0
        public async Task <IActionResult> Index()
        {
            if (!_memoryCache.TryGetValue("ListOfILeagues", out IPagedList <League> leagues))
            {
                leagues = await _leagueService.FilterLeaguesAsync();

                MemoryCacheEntryOptions options = new MemoryCacheEntryOptions
                {
                    AbsoluteExpirationRelativeToNow = TimeSpan.FromSeconds(25),
                    SlidingExpiration = TimeSpan.FromSeconds(5)
                };

                _memoryCache.Set("ListOfILeagues", leagues, options);
            }

            var model = new LeagueIndexViewModel(leagues);

            return(View(model));
        }