Windows Server AppFabric 缓存(微软分布式缓存解决方案)
2011-07-25 00:03
239 查看
主要介绍一下Windows Server AppFabric特点,详细的介绍及代码参照MSDN,这里就不多此一举了。(同类产品Memcahed)
Windows Server AppFabric 扩展了 Windows Server 以为 Web
应用程序和中间层服务提供增强的托管、管理和缓存功能。 AppFabric 托管功能向 Internet 信息服务 (IIS)、Windows
Process Activation Service (WAS) 和 .NET Framework 4
添加了服务管理扩展。其中包括托管服务和托管管理工具,这些工具使部署、配置和管理基于 Windows Communication
Foundation (WCF) 和 Windows Workflow Foundation (WF) 的服务变得更加容易。 AppFabric
缓存功能向 Windows Server 添加了一个分布式的内存中对象缓存,它使扩展高性能 .NET 应用程序(特别是 ASP.NET
应用程序)变得更加容易。使用 AppFabric 缓存功能,您可以将多台计算机的内存容量合并到一个统一的缓存群集,从而可以帮助您轻松且低廉地扩展
.NET 应用程序。 这些功能包括缓存服务、缓存客户端和缓存管理工具。
缓存功能使用彼此通信的服务器群集来形成单个统一的应用程序缓存系统。作为分配式缓存系统,所有缓存操作都抽象为单个参考点,称作缓存群集。换句话说,无
论构成缓存群集的计算机有多少台,您的客户端应用程序都可以与群集中单个逻辑单元的缓存配合使用。
物理体系结构的主要组件包含缓存服务器、缓存主机 Windows 服务、缓存群集、基于 Windows PowerShell 的缓存管理工具、群集配置存储位置和缓存客户端。下图显示所有这些元素的关联情况。
View Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--configSections must be the FIRST element -->
<configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<!-- cache client -->
<dataCacheClient>
<!-- cache host(s) -->
<hosts>
<host
name="CacheServer1"
cachePort="22233"/>
</hosts>
</dataCacheClient>
<system.web>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
<providers>
<!-- specify the named cache for session data -->
<add
name="AppFabricCacheSessionStoreProvider"
type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider"
cacheName="NamedCache1"
sharedId="SharedApp"/>
</providers>
</sessionState>
</system.web>
</configuration>
// Declare array for cache host(s).
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
servers[0] = new DataCacheServerEndpoint("CacheServer2", 22233);
// Setup the DataCacheFactory configuration.
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
// Create a configured DataCacheFactory object.
DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig);
// Get a cache client for the cache "NamedCache1".
DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1");
//myDefaultCache.CreateRegion("Area1"); //create region
总体来看,默认支持asp.net
sesseion配置,实现代码及配置文件都很简单,并且扩展了缓存区域及缓存标签功能,帮助划分区域及区分数据。尤其是本地缓存功能大大提高了检索效率
(针对不变化数据),同时针对本地缓存过期也提供了过期和逐出机制。不过安装比较麻烦,建议使用Web PlatForm
Instraller安装,里面会将指定的更新补丁及PowerShell一并下载更新了。相比Memcached功能强大,但没有Memcached配
置和扩展简单,各有所长。
另外.NET 4.0支持缓存扩展,你可以继承ObjectCache实现自己的缓存机制。
Windows Server AppFabric 扩展了 Windows Server 以为 Web
应用程序和中间层服务提供增强的托管、管理和缓存功能。 AppFabric 托管功能向 Internet 信息服务 (IIS)、Windows
Process Activation Service (WAS) 和 .NET Framework 4
添加了服务管理扩展。其中包括托管服务和托管管理工具,这些工具使部署、配置和管理基于 Windows Communication
Foundation (WCF) 和 Windows Workflow Foundation (WF) 的服务变得更加容易。 AppFabric
缓存功能向 Windows Server 添加了一个分布式的内存中对象缓存,它使扩展高性能 .NET 应用程序(特别是 ASP.NET
应用程序)变得更加容易。使用 AppFabric 缓存功能,您可以将多台计算机的内存容量合并到一个统一的缓存群集,从而可以帮助您轻松且低廉地扩展
.NET 应用程序。 这些功能包括缓存服务、缓存客户端和缓存管理工具。
Windows Server AppFabric 缓存物理体系结构示意图
Windows Server AppFabric缓存功能使用彼此通信的服务器群集来形成单个统一的应用程序缓存系统。作为分配式缓存系统,所有缓存操作都抽象为单个参考点,称作缓存群集。换句话说,无
论构成缓存群集的计算机有多少台,您的客户端应用程序都可以与群集中单个逻辑单元的缓存配合使用。
物理体系结构的主要组件包含缓存服务器、缓存主机 Windows 服务、缓存群集、基于 Windows PowerShell 的缓存管理工具、群集配置存储位置和缓存客户端。下图显示所有这些元素的关联情况。
View Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<!--configSections must be the FIRST element -->
<configSections>
<!-- required to read the <dataCacheClient> element -->
<section name="dataCacheClient"
type="Microsoft.ApplicationServer.Caching.DataCacheClientSection,
Microsoft.ApplicationServer.Caching.Core, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35"
allowLocation="true"
allowDefinition="Everywhere"/>
</configSections>
<!-- cache client -->
<dataCacheClient>
<!-- cache host(s) -->
<hosts>
<host
name="CacheServer1"
cachePort="22233"/>
</hosts>
</dataCacheClient>
<system.web>
<sessionState mode="Custom" customProvider="AppFabricCacheSessionStoreProvider">
<providers>
<!-- specify the named cache for session data -->
<add
name="AppFabricCacheSessionStoreProvider"
type="Microsoft.ApplicationServer.Caching.DataCacheSessionStoreProvider"
cacheName="NamedCache1"
sharedId="SharedApp"/>
</providers>
</sessionState>
</system.web>
</configuration>
示例代码
View Code// Declare array for cache host(s).
DataCacheServerEndpoint[] servers = new DataCacheServerEndpoint[1];
servers[0] = new DataCacheServerEndpoint("CacheServer2", 22233);
// Setup the DataCacheFactory configuration.
DataCacheFactoryConfiguration factoryConfig = new DataCacheFactoryConfiguration();
factoryConfig.Servers = servers;
// Create a configured DataCacheFactory object.
DataCacheFactory mycacheFactory = new DataCacheFactory(factoryConfig);
// Get a cache client for the cache "NamedCache1".
DataCache myDefaultCache = mycacheFactory.GetCache("NamedCache1");
//myDefaultCache.CreateRegion("Area1"); //create region
总体来看,默认支持asp.net
sesseion配置,实现代码及配置文件都很简单,并且扩展了缓存区域及缓存标签功能,帮助划分区域及区分数据。尤其是本地缓存功能大大提高了检索效率
(针对不变化数据),同时针对本地缓存过期也提供了过期和逐出机制。不过安装比较麻烦,建议使用Web PlatForm
Instraller安装,里面会将指定的更新补丁及PowerShell一并下载更新了。相比Memcached功能强大,但没有Memcached配
置和扩展简单,各有所长。
另外.NET 4.0支持缓存扩展,你可以继承ObjectCache实现自己的缓存机制。
相关文章推荐
- Windows Server AppFabric 缓存(微软分布式缓存解决方案)
- Windows Server AppFabric 缓存(微软分布式缓存解决方案)
- Windows Server AppFabric 缓存(微软分布式缓存解决方案)
- Windows Server AppFabric 缓存(微软分布式缓存解决方案)问斩摘自小城岁月
- Windows Server AppFabric 缓存(微软分布式缓存解决方案)
- 使用微软分布式缓存服务Velocity(Windows Server AppFabric Caching Service)
- 微软分布式缓存 AppFabric(Velocity)-开发篇(二)缓存的基础方法使用
- 微软分布式缓存 AppFabric(Velocity)学习-缓存概念(一)
- 微软分布式缓存 AppFabric(Velocity)-开发篇(四)缓存通知
- 使用微软分布式缓存服务Velocity Part 1——转自 博客园 Terrylee
- Windows Server AppFabric缓存参考实例和方案选择 2/3
- session-缓存-分布式会话session共享、多节点部署session共享解决方案
- 使用微软分布式缓存服务Velocity Part 2——博客园 Terrylee
- 使用微软分布式缓存服务Velocity Part 3——博客园 Terrylee
- Memcahed分布式缓存服务替换Session解决方案——简单介绍[转]
- Memcahed分布式缓存服务替换Session解决方案
- 使用微软分布式缓存服务Velocity Part 1
- Memcahed分布式缓存服务替换Session解决方案
- 微软高性能缓存AppFabric (一) 安装
- Memcahed分布式缓存服务替换Session解决方案