我試圖在我的輔助角色實例之間設置緩存。爲此,我向Azure項目添加了一個新的緩存輔助角色。但是,當我嘗試使用以下代碼訪問默認緩存時:將Azure輔助角色連接到專用緩存輔助角色
_dataCacheFactory = new DataCacheFactory();
var cache = _dataCacheFactory.GetDefaultCache();
我永遠不會獲得默認緩存,並且呼叫超時。我複製從Azure的文檔,我的app.config文件,並在標識符標記添加我的角色名:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataCacheClients" type="Microsoft.ApplicationServer.Caching.DataCacheClientsSection, Microsoft.ApplicationServer.Caching.Core" allowLocation="true" allowDefinition="Everywhere" />
<section name="cacheDiagnostics" type="Microsoft.ApplicationServer.Caching.AzureCommon.DiagnosticsConfigurationSection, Microsoft.ApplicationServer.Caching.AzureCommon" allowLocation="true" allowDefinition="Everywhere" />
</configSections>
<dataCacheClients>
<dataCacheClient name="default">
<autoDiscover isEnabled="true" identifier="Cache" />
<!--<localCache isEnabled="true" sync="TimeoutBased" objectCount="100000" ttlValue="300" />-->
</dataCacheClient>
</dataCacheClients>
<cacheDiagnostics>
<crashDump dumpLevel="Off" dumpStorageQuotaInMB="100" />
</cacheDiagnostics>
</configuration>
我已仔細檢查了我的緩存工人角色的名稱確實是「高速緩存」。在我的緩存工作者的角色和我的正常工作者角色都,我已經設置了下面的事情在配置選項卡中的「緩存」選項卡:
- 啓用高速緩存
- 設置成「專用角色」緩存集羣設置
- 存儲帳戶憑據:UseDevelopmentStorage =真
我目前在Azure計算模擬器中運行這個。我可以看到,我的工作者角色和緩存工作者角色都已啓動並正在運行。是否有一些配置設置,我錯過了或設置不正確?謝謝!
請看看這個線程,看看是否不會導致你遇到的問題:http://stackoverflow.com/questions/18045279/configure-azure-shared-cache-locally-and-on-the -cloud/18046481#18046481。 –
緩存功能僅適用於Azure,但在模擬器上不適用。你有沒有試圖在Azure上運行它,你有什麼錯誤? –
@VladimirDorokhov - 我不確定這句話是否正確。緩存功能可以在模擬器和雲中使用。 –