azure - 以编程方式配置 Azure 缓存客户端

标签 azure memcached

我刚刚通过 nuGet 更新到最新的 Azure dll(ID:Microsoft.WindowsAzure.Caching 版本 2.0.0.0,运行时版本 v4)。这使我能够为我的角色配置共享缓存。

问题是当我尝试以编程方式访问 AppFabric Memcache(另一个缓存,与 session 无关)时。

var servers = new List<DataCacheServerEndpoint>();
servers.Add(new DataCacheServerEndpoint(_hostname, _cacheport));
var conf = new DataCacheFactoryConfiguration();
conf.SecurityProperties = new DataCacheSecurity(secure(_authinfo));
var dataCacheFactory = new DataCacheFactory(conf);
_dataCache = dataCacheFactory.GetDefaultCache();

代码编译正常,但抛出运行时错误:

Method not found: 'Void Microsoft.ApplicationServer.Caching.DataCacheSecurity..ctor(System.Security.SecureString)'.

如果我使用这段代码并将 dll 放入运行时版本 2,效果会非常好。

知道我应该更改什么才能使其正常工作吗?

编辑:

看起来 DataCacheSecurity 的旧构造函数不再允许安全 token

http://msdn.microsoft.com/en-us/library/microsoft.applicationserver.caching.datacachesecurity.datacachesecurity(v=ws.10).aspx

现在我只有 2 个构造函数,看起来不可能指定身份验证 key

编辑2:

我联系了 Microsoft,他们告诉我:

“Windows Azure 缓存和 Windows Azure 共享缓存共享相同的 API,尽管程序集名称相同,但程序集本身不同且位于不同位置。缓存 NuGet 包将删除共享缓存程序集引用并添加正确的缓存程序集引用。缓存程序集位于 C:\Program Files\Microsoft SDKs\Windows Azure.NET SDK\2012-10\ref\Caching 文件夹中。”

结论:目前不可能。

最佳答案

目前,新的 Azure 缓存 .DLL (v2) 与以前的版本不兼容。您需要选择一个版本并确保您的所有提供商都遵守它。显然,专用缓存需要 v2.0 的 DataCache DLL。

关于azure - 以编程方式配置 Azure 缓存客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16813664/

相关文章:

azure - 使用 Azure 功能备份 Sharepoint Online

c# - Azure Redis 缓存 : Reading is not allowed after reader was completed

用于停止 key 过期的 Memcached 设置

google-app-engine - 您可以在 App Engine 上传递给 memcache.get_multi 的 key 数量的实际限制是多少?

linux - 如何设置在不同端口上运行的多个 memcached 实例?

caching - 过夜预热缓存摘要

Azure 网站从源代码管理部署因 nuget 依赖项而失败

javascript - Bootstrap 3 轮播的问题

sql-server - 请解释一下 SQL Azure "master"数据库

django - Memcached 比较并设置模式产生错误结果