为什么我的httpcontext.cache在localhost中工作但不在生产中?

时间:2011-10-06 16:30:15

标签: c# .net asp.net caching webserver

我正在使用HttpContext.Cache来缓存我的数据,但它只适用于我的localhost。

在生产中,缓存不起作用,我的方法总是到我的数据库中检索数据,而不是从缓存中捕获它们。我只使用一个Sql Server实例和一个Web服务器。

我的代码就像这样

 protected void LoadMenuSistem()
        {
            string menu = ""; 
            if (Cache["menuSistem"] != null)
            {
                Response.Write(Cache["menuSistem"].ToString());
            }
            else
            {
                  // Retrive data from  database and populate the string menu
            }

            Cache["menuSistem"] = menu;
}

1 个答案:

答案 0 :(得分:1)

请检查生产服务器中的CPU使用率和RAM大小。根据优先级设置,将要删除的服务器缓存项目中的内存不足以释放内存。这个过程被称为清理。