Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it support Application cache in multiple server in asp.net(C#)?

Is it support Application cache in multiple server in asp.net(C#). I know application variable is not supporting in multiple server (web farms), But what about application cache? .Will be there any issue whiling access the values or it not worth to store values in application cache when we are going with multiple server? (Database storing not suitable, it will take more load). Here i am using codes

     HybridDictionary dicApplicationVariable = new HybridDictionary();
                    if (HttpContext.Current.Cache["dicApplicationVariable"] != null)
                    {
                        dicApplicationVariable = (HybridDictionary)HttpContext.Current.Cache["dicApplicationVariable"];
                        if (dicApplicationVariable.Contains(dtUserLogin.Rows[0]["Id"]))
                        {
                            dicApplicationVariable.Remove(dtUserLogin.Rows[0]["Id"]);
                            dicApplicationVariable.Add(dtUserLogin.Rows[0]["Id"], LogginSessionID);
                        }
                        else
                        {
                            dicApplicationVariable.Add(dtUserLogin.Rows[0]["Id"], LogginSessionID);
                        }
                    }
                    else
                    {
                        dicApplicationVariable.Add(dtUserLogin.Rows[0]["Id"], LogginSessionID);
                        HttpContext.Current.Cache["dicApplicationVariable"] = dicApplicationVariable;
                    }
like image 696
Haris N I Avatar asked Aug 29 '13 12:08

Haris N I


1 Answers

If you are running Windows Server 2008 or later, then I would look into Windows Server AppFabric Caching.

Windows Server AppFabric extends Windows Server to provide enhanced hosting, management, and caching capabilities for Web applications and middle-tier services. The AppFabric hosting features add service management extensions to Internet Information Services (IIS), Windows Process Activation Service (WAS), and the .NET Framework 4. This includes Hosting Services and Hosting Administration tools that make it easier to deploy, configure, and manage Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) based services. The AppFabric caching features add a distributed, in-memory object cache to Windows Server that makes it easier to scale out high-performance .NET applications, especially ASP.NET applications.

I realize that not everyone will want to use Microsoft products, so here are some alternatives to AppFabric:

  • NCache - this is a third party, not free, solution
  • Redis via Open Source C# Client for Redis - ServiceStack. Here is an interesting read on .NET Application Caching: Redis vs. AppFabric Caching 1.1.
like image 61
Karl Anderson Avatar answered Oct 02 '22 17:10

Karl Anderson