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

标签 c# asp.net caching

它是否支持在 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/

相关文章:

c# - dotnet 核心 3.1 IIS 错误 "An attempt was made to access a socket in a way forbidden by its access permissions (10013)"

c# - 返回 View 后未调用 ASP.NET 索引方法

c# - 是否可以通过编程方式设置 MasterType?

ruby-on-rails - Rails 3.1通配符使缓存与查询字符串一起作用

regex - htaccess 目标特定文件

c# - 为什么在从字典中读取时锁定

c# - 读取 XML 中的下一个节点 (Linq to XML C#)

c# - 如何全局设置 System.Text.Json.JsonSerializer 的默认选项?

c# - 在最小起订量中重置模拟验证?

asp.net - MVC 自定义成员资格和角色提供者上下文生命周期问题