1

There is an awesome attribute OutputCache

[OutputCache(Duration = 60*60 )]
public ActionResult Index()

And it is working fine, but only in case the method is controller's Action Method (the reason is in the code which invokes actionMethod).

I want to store the output of some other method of controller (for instance, the code performs some queries to database and returns a collection)

Is there a mechanism like OutputCacheAttribute? Оr I should write my own caching code?

Thanks in advance!

Alleo
  • 7,891
  • 2
  • 40
  • 30

1 Answers1

1

You can use the ASP.NET Cache to store data like this. I would recommend against using your own caching model, as you will need to reinvent the wheel on issues like thread safety, stale cache, memory management etc. See also this post : Caching in asp.net-mvc

Community
  • 1
  • 1
StuartLC
  • 104,537
  • 17
  • 209
  • 285
  • Thanks for the link, but I've expected to hear about something which is very close in use (I mean, uses attributes). Seems there are no such ways. A link where out-of-the-box methods are collected: http://msdn.microsoft.com/en-us/library/dd997357(v=vs.100).aspx – Alleo Sep 11 '12 at 14:25