Exemplo n.º 1
0
        public async Task <IActionResult> Index()
        {
            if (!_memoryCache.TryGetValue("ListOfMatches", out IPagedList <Match> matches))
            {
                matches = await _matchService.FilterMatchesAsync();

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

                _memoryCache.Set("ListOfMatches", matches, options);
            }

            var model = new MatchIndexViewModel(matches);

            return(View(model));
        }