> For the complete documentation index, see [llms.txt](https://jen-hsuan-hsieh.gitbook.io/asp-net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jen-hsuan-hsieh.gitbook.io/asp-net/chapter1/1.1.the-complete-asp.net-mvc-5-course/19performance-optimization/195data-cache.md).

# 1.9.5.Data Cache

* Use data cache

  ```
    public ViewResult Index()
        {
            if (MemoryCache.Default["Genre"] == null)
            {
                MemoryCache.Default["Genre"] = _context.genreType.ToList();
            }

            var genres = MemoryCache.Default["Genre"] as IEnumerable<Genre>;

            return View();
        }
  ```
* Poor advice in 2 reasons:
  * 1.By blindly storing data in the cache you will increase memory consumption of your application
  * 2.It will lead to all kinds of unnecessary complexities both at the architectural and code level especially when you're working with entity framework
