gpt4 book ai didi

c# - 它是否支持在 asp.net(C#) 中的多个服务器中的应用程序缓存?

转载 作者:太空狗 更新时间:2023-10-29 20:30:54 27 4
gpt4 key购买 nike

它是否支持在 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 的替代品:

关于c# - 它是否支持在 asp.net(C#) 中的多个服务器中的应用程序缓存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18511552/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com