Reputation: 32778
My code already has things like this in the controller:
[OutputCache(Duration = 86400]
public string SelectTopics(bool showAll = true, string topicID = null)
{
return SelectHelper.Topics(showAll, topicID);
}
Am I correct in saying this will be cached?
How about in external non-controller classes and methods. Is there any way I can have database caching with these or must all database caching be through a controller? What about other ways/means of accessing the data. Anything else that allows caching?
Upvotes: 0
Views: 127
Reputation: 1038750
Am I correct in saying this will be cached?
This caches the entire HTML output. It means that the controller action will not even be executed if the output is cached. And in this case the SelectHelper.Topics
won't run.
Other ways of caching data involve using classes in the System.Runtime.Caching namespace. They allow you to store NET objects into cache. For example you could store the results retrieved from a database call into the cache and then check whether the cache contains those results before hitting the database the next time. You may take a look at the MemoryCache class for an example.
Upvotes: 2