利用 Azure 缓存服务增强 Sitecore





5.00/5 (1投票)
开箱即用的 Sitecore Azure 安装使用角色内缓存。本文提供了一种使用 Azure 缓存服务的替代方案。
引言
当我开始研究在 Windows Azure 上托管 Sitecore 时,使用了 Sitecore 提供的模块,我注意到默认设置使用的是角色内缓存。这意味着你的 Web 角色的部分内存将被用于缓存,而不能用于处理 Web 请求。有些人可能会说“没问题”,如果需要处理更多请求,我只需扩展即可。从本质上讲,这是正确的,但根据你的解决方案需求,这可能会带来成本。因此,我想知道 Windows Azure 中是否有其他可用的选项。
Windows Azure 提供了各种 缓存选项
- 角色内缓存
- 托管缓存服务
- Azure Redis 缓存
选项 2 和 3 是允许你将缓存从 Web 角色中移除的服务,这可能在成本上是有益的,具体取决于你的需求。使用专用缓存服务有时更便宜,并且在可扩展性方面可能表现更好。
在本文中,我将描述如何在 Sitecore 中配置 Azure Redis 缓存,但你可以使用相同的方法来使用托管缓存服务。
在 Windows Azure 中配置新的 Redis 缓存
我选择了带有 1GB 内存和复制功能的标准层。根据你的需求和 Sitecore 解决方案中包含的项目数量,你可能需要考虑其他计划。
更改 Sitecore Azure 设置
好的,现在进入有趣的部分了。
导航到 'sitecore/system/modules/azure/{your-deployment}/{azure-region}/Editing01/Role01/Production'。
编辑以下字段 '[请勿编辑!] - 全局 Web Config Patch (这些全局 Web Config Patch 将始终应用于每个部署)'
替换这一行
<add name="DistributedCacheSessionStateStoreProvider" type="Microsoft.Web.DistributedCache.DistributedCacheSessionStateStoreProvider, Microsoft.Web.DistributedCache" cacheName="default" useBlobMode="true" dataCacheClientName="default" />
<add name="DistributedCacheSessionStateStoreProvider" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="sitecore.redis.cache.windows.net" port="6379" accessKey="paste-your-access-key-in-here" ssl="false" throwOnError="false" retryTimeoutInMilliseconds="20" />
删除以下行
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
删除以下行
<xsl:param name="pDataCacheClients"> <dataCacheClients> <dataCacheClient name="default" isCompressionEnabled="false"> <autoDiscover isEnabled="true" identifier="SitecoreWebRole" /> <localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" /> </dataCacheClient> </dataCacheClients> <cacheDiagnostics> <crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" scheduledTransferPeriodInMinutes="5" /> </cacheDiagnostics> </xsl:param>
删除以下行
<xsl:copy-of select="$pDataCacheClients" />
安装 Redis NuGet 包
在你的网站解决方案中,从 NuGet 安装 RedisSessionStateProvider 包。
部署
现在是时候构建、发布并将你的 Sitecore 解决方案重新部署到 Windows Azure 了。