2

我可以在负载平衡服务器中使用 Microsoft 企业库缓存吗?我的情况是我有一个位于 2 个负载平衡服务器中的 Web 服务,并且我使用具有如下配置的数据库缓存“backingStores”

<cachingConfiguration defaultCacheManager="Cache Manager">
    <cacheManagers>
        <add name="Cache Manager" type="Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" expirationPollFrequencyInSeconds="60" maximumElementsInCacheBeforeScavenging="1000" numberToRemoveWhenScavenging="10" backingStoreName="MyDataCacheStorage11"/>
    </cacheManagers>
    <backingStores>
        <add name="MyDataCacheStorage11" type="Microsoft.Practices.EnterpriseLibrary.Caching.Database.DataBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching.Database, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" encryptionProviderName="" databaseInstanceName="EntLib1ConnectionString111" partitionName="CAPwiki Cache"/>
        <add type="Microsoft.Practices.EnterpriseLibrary.Caching.BackingStoreImplementations.NullBackingStore, Microsoft.Practices.EnterpriseLibrary.Caching, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="NullBackingStore"/>
    </backingStores>
</cachingConfiguration>

当我从 server1 使用键“ _testorderstatus3 ”设置缓存并尝试从 server2 获取它时,它返回 Null 值!

同样,当我从 server1 使用相同的键设置值并从 server2 再次设置时,我检查了数据库,我发现它设置了 2 次,如下所示 在此处输入图像描述

有什么想法吗?我需要设置并进入两台服务器。

谢谢

4

1 回答 1

3

Enterprise Library 不支持开箱即用的分布式多服务器缓存解决方案。来自开发人员指南的第 5 章

开箱即用的缓存应用程序块不提供跨多个服务器的分布式缓存所需的功能。

根据您要执行的操作,我将查看Windows Server AppFabric Caching Services

Windows Server AppFabric 提供了一个分布式内存应用程序缓存平台,用于开发可扩展、可用和高性能的应用程序。

于 2011-10-18T04:29:39.623 回答