I have an action in my MVC controller, and I want to cache its return result on the basis of passed parameters as a key, so that next time this action will be called it will first look in cache if not found it will look in Data storage.
public ActionResult GetSearchResult(string zipcode, int pageSize, int currentPage)
{
Cache[zipcode + page + currentpage] = somedata // but it should be cleared after 30 min
}
How can I do this? I can store the data in the cache object, as above, but I want to ensure that cached objects are cleared after 30 minutes. I can’t see how to configure the lifetime either on a global or per-cached-object basis.
I strongly suggest using the outputcache filter on your action, rather than doing it manually yourself