Question
Caching Data Objects when using Repository/Service Pattern and MVC
I have an MVC-based site, which is using a Repository/Service pattern for data access. The Services are written to be using in a majority of applications (console, winform, and web). Currently, the controllers communicate directly to the services. This has limited the ability to apply proper caching.
I see my options as the following:
- Write a wrapper for the web app, which implements the IWhatEverService which does caching.
- Apply caching in each controller by cache the ViewData for each Action.
- Don't worry about data caching and just implement OutputCaching for each Action.
I can see the pros and cons of each. What is/should the best practice be for caching with Repository/Service