Har*_*ris 7 c# asp.net caching
它是否支持asp.net(C#)中多个服务器中的应用程序缓存.我知道应用程序变量不支持多个服务器(Web场),但应用程序缓存呢?.当我们使用多个服务器时,是否存在访问值的问题或者不值得在应用程序缓存中存储值?(数据库存储不合适,需要更多负载).我在这里使用代码
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;
}
Run Code Online (Sandbox Code Playgroud)
如果您运行的是 Windows Server 2008 或更高版本,那么我会研究Windows Server AppFabric Caching。
Windows Server AppFabric 扩展了 Windows Server,为 Web 应用程序和中间层服务提供增强的托管、管理和缓存功能。AppFabric 托管功能将服务管理扩展添加到 Internet 信息服务 (IIS)、Windows 进程激活服务 (WAS) 和 .NET Framework 4。这包括托管服务和托管管理工具,可以更轻松地部署、配置和管理基于 Windows Communication Foundation (WCF) 和 Windows Workflow Foundation (WF) 的服务。AppFabric 缓存功能将分布式内存中对象缓存添加到 Windows Server,从而可以更轻松地扩展高性能 .NET 应用程序,尤其是 ASP.NET 应用程序。
我意识到并不是每个人都想使用 Microsoft 产品,因此这里有一些 AppFabric 的替代品: