Пример #1
0
        public IEnumerable <MenuItemDto> GetAllMenuItems()
        {
            IEnumerable <MenuItemDto> menuItems;

            if (!_cache.TryGetValue("MenuItems", out menuItems))
            {
                Console.WriteLine("HEY EG ER EKKI MEÐ ÞETTA Boi");
                var cacheEntryOptions = new MemoryCacheEntryOptions().SetSlidingExpiration(TimeSpan.FromHours(8));
                menuItems = _repo.GetAllMenuItems();
                _cache.Set("MenuItems", menuItems, cacheEntryOptions);
            }
            return(menuItems);
        }