从缓存中删除值

cache-remove-value 删除通过密钥标识的缓存项。 密钥的值可以是任意字符串,通常使用策略表达式来提供密钥。

注意

按照策略声明中提供的顺序设置策略的元素和子元素。 详细了解如何设置或编辑 API 管理策略

策略语句

<cache-remove-value key="cache key value" caching-type="prefer-external | external | internal"  />

属性

属性 说明 需要 默认
caching-type 在以下属性值之间进行选择:
- internal,表示可使用内置的 API 管理缓存
- external 使用外部缓存,如- 中所述;
- prefer-external 如果外部缓存已配置,则使用外部缓存,否则使用内部缓存。

不允许使用策略表达式。
prefer-external
key 以前所缓存的值(将从缓存中删除)的密钥。 允许使用策略表达式。 空值

使用情况

示例

<cache-store-value
    key="@("userprofile-" + context.Variables["enduserid"])"
    value="@((string)context.Variables["userprofile"])" duration="100000" />

有关此策略的详细信息和示例,请参阅 Azure API 管理中的自定义缓存

后续步骤

有关使用策略的详细信息,请参阅: