它是否支持在 asp.net(C#) 中的多个服务器中的应用程序缓存。我知道应用程序变量在多服务器(网络场)中不支持,但是应用程序缓存呢? .当我们使用多个服务器时,访问值时会不会有任何问题,或者不值得将值存储在应用程序缓存中? (数据库存储不合适,会占用更多负载)。我在这里使用代码
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;
}
最佳答案
如果您运行的是 Windows Server 2008 或更高版本,那么我会查看 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.
我知道不是每个人都想使用 Microsoft 产品,所以这里有一些 AppFabric 的替代品:
- NCache - 这是第三方解决方案,不是免费的
- Redis 通过 Open Source C# Client for Redis - ServiceStack .这是关于 .NET Application Caching: Redis vs. AppFabric Caching 1.1 的有趣读物.
关于c# - 它是否支持在 asp.net(C#) 中的多个服务器中的应用程序缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18511552/