MemoryCache.Item[String] 属性

定义

通过使用 MemoryCache 类的实例的默认索引器属性,获取或设置缓存中的值。

public:
 virtual property System::Object ^ default[System::String ^] { System::Object ^ get(System::String ^ key); void set(System::String ^ key, System::Object ^ value); };
public override object this[string key] { get; set; }
member this.Item(string) : obj with get, set
Default Public Overrides Property Item(key As String) As Object

参数

key
String

要获取或设置的缓存值的唯一标识符。

属性值

如果该项存在,则为指定键的缓存实例中的值;否则为 null

例外

key 上声明的默认值为 null

- 或 -

插入的值为 null

注解

设置此属性时,值将插入缓存中。 缓存条目的过期策略设置为 InfiniteAbsoluteExpiration。 如果已存在具有匹配键的缓存项,则会更新其值。

适用于