c# - 如何在不知道区域的情况下通过标签从缓存中获取项目

标签 c# appfabric

我们正在使用 MS Velocity,并将很快转向 AppFabric。我们有兴趣将来可能使用标签从缓存中检索项目。 Velocity/App Fabric API 包含一个添加方法,如下所示

public DataCacheItemVersion Add(string key, 
                                object value, 
                                IEnumerable<DataCacheTag> tags);

但是,没有任何方法可用于使用不需要指定区域的标记从缓存中检索对象。

问题在于,如果您使用 Add() 而不指定区域,您将不知道缓存管理器将对象放入哪个区域;因此,您在检索对象时无法指定区域。我在这里错过了一些非常简单的东西吗?

最佳答案

如果您使用 DataCache 类,则有多个可用的重载,包括第一个仅指定键的重载:

  • DataCache.Get (String) - Gets an object from the cache using the specified key.
  • DataCache.Get (String, out DataCacheItemVersion) - Gets an object from the cache using the specified key. You may also provide the version to obtain the specific version of a key, if that version is still the most current in the cache.
  • DataCache.Get (String, String) - Gets an object from the specified region by using the specified key.
  • DataCache.Get (String, out DataCacheItemVersion, String) - Gets an object from the specified region by using the specified key. You may also provide the version to obtain the specific version of a key, if that version is still the most current in the region.

来自 http://msdn.microsoft.com/en-us/library/microsoft.data.caching.datacache.get.aspx

关于c# - 如何在不知道区域的情况下通过标签从缓存中获取项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5316564/

相关文章:

c# - 如何在 macOS 的 dotnet MAUI 中设置启动页面大小(net6.0-maccatalyst)

C#:使用匿名函数排序

c# - 如何从矢量或 ImageTargets 列表生成随机目标

Azure appfabric服务总线负载平衡+ session 关联(粘性 session )

entity-framework - 在 Azure AppFabric 中缓存 Entity Framework 结果

ssh - 代理/ServiceBus/反向SSH

c# - 使用 Azure SQL 作为配置存储的 AppFabric 缓存

c# - 从 LINQ to Entities 存储数据的最有效集合?

c# - SQL Server 日期时间舍入

wcf - 元素 'behavior' 具有无效的子元素 'transportClientEndpointBehavior' 也是 basicHttpRelayBinding