How to cache data in a MVC application

后端 未结 14 1285
鱼传尺愫
鱼传尺愫 2020-11-22 11:39

I have read lots of information about page caching and partial page caching in a MVC application. However, I would like to know how you would cache data.

In my scena

14条回答
  •  深忆病人
    2020-11-22 12:06

    Steve Smith did two great blog posts which demonstrate how to use his CachedRepository pattern in ASP.NET MVC. It uses the repository pattern effectively and allows you to get caching without having to change your existing code.

    http://ardalis.com/Introducing-the-CachedRepository-Pattern

    http://ardalis.com/building-a-cachedrepository-via-strategy-pattern

    In these two posts he shows you how to set up this pattern and also explains why it is useful. By using this pattern you get caching without your existing code seeing any of the caching logic. Essentially you use the cached repository as if it were any other repository.

提交回复
热议问题