【发布时间】:2011-09-25 21:46:05
【问题描述】:
我有以下代码来缓存一些昂贵的代码。
private MyViewModel GetVM(Params myParams)
{
string cacheKey = myParams.runDate.ToString();
var cacheResults = HttpContext.Cache[cacheKey] as MyViewModel ;
if (cacheResults == null)
{
cacheResults = RunExpensiveCodeToGenerateVM(myParams);
HttpContext.Cache[cacheKey] = cacheResults;
}
return cacheResults;
}
这会永远留在缓存中吗?直到服务器重新启动或内存不足?
【问题讨论】:
标签: c# asp.net-mvc caching httpcontext.cache