7

I currently use the repository pattern in my ASP.NET MVC 3 app.

I use OutputCache to lessen the load on my database by decorating my controller methods with a data annotation similar to this:

[OutputCache(Duration = 3600, VaryByParam = "userName")]

Ultimately, what I'd like to achieve is a level of caching whereby the data is cached until it is updated (i.e. it changes). I am using Entity Framework 4.1 for ORM.

What would be the recommended way to approach this using my selected stack?

harriyott
  • 10,505
  • 10
  • 64
  • 103
Nick
  • 5,844
  • 11
  • 52
  • 98
  • possible duplicate of [Expire Output Cache ASP.Net MVC](http://stackoverflow.com/questions/376851/expire-output-cache-asp-net-mvc) – jrummell Apr 03 '12 at 19:20
  • How will you know when your data is updated? If you are assuming that you will manage the state of an object by using your controllers you could manipulate the cache: http://stackoverflow.com/questions/11585/clearing-page-cache-in-asp-net – Nick Bork Apr 03 '12 at 19:20

2 Answers2

4

see http://msdn.microsoft.com/en-us/library/hdxfb6cy(v=vs.85).aspx

There's a SqlDependency attribute :-)

Rowan Freeman
  • 15,724
  • 11
  • 69
  • 100
Smartkid
  • 1,772
  • 2
  • 25
  • 34
1

Check out this article: http://msdn.microsoft.com/en-us/magazine/gg650661.aspx

A custom provider would be the only way.

Brian Mains
  • 50,520
  • 35
  • 148
  • 257