public ActionResult Index()
        {
            const string key   = "books";
            var          books = CacheEngine.Get <List <Book> >(key);

            if (books == null)
            {
                books = BookData.GetBooks();
                CacheEngine.Add(key, books);
            }

            ViewBag.books = books;
            return(View());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            const string key = "books";

            var books = CacheEngine.Get <List <Book> >(key);

            if (books == null)
            {
                books = BookData.GetBooks();
                CacheEngine.Add(key, books);
            }

            var cachedBooks = CacheEngine.Get <List <Book> >(key);

            foreach (var book in books)
            {
                System.Console.WriteLine(book.Name);
            }

            System.Console.ReadKey();
        }