开发者

Why my httpcontext.cache works in localhost but not production?

开发者 https://www.devze.com 2023-04-11 11:25 出处:网络
I am using HttpContext.Cache to cache my data but it only works in my localhost. In production, the cache doesn\'t works, my method always go to my database retrive the data, instead catch them from

I am using HttpContext.Cache to cache my data but it only works in my localhost.

In production, the cache doesn't works, my method always go to my database retrive the data, instead catch them from the cache. I use just one instance of Sql Server and one web server.

My code is like this

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

            Cache["menuSistem"] = menu;
}


please check the CPU Usage and RAM size in your production server. incase of low memory in the server cached items to be removed to free memory based on the priority set. This process is known as scavenging.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号