Get value from cache
cache-lookup-value policy to perform cache lookup by key and return a cached value. The key can have an arbitrary string value and is typically provided using a policy expression.
This policy must have a corresponding Store value in cache policy.
Built-in cache is volatile and is shared by all units in the same region in the same API Management service.
Set the policy's elements and child elements in the order provided in the policy statement. Learn more about how to set or edit API Management policies.
<cache-lookup-value key="cache key value" default-value="value to use if cache lookup resulted in a miss" variable-name="name of a variable looked up value is assigned to" caching-type="prefer-external | external | internal" />
|caching-type||Choose between the following values of the attribute:
Policy expressions aren't allowed.
|default-value||A value that will be assigned to the variable if the cache key lookup resulted in a miss. If this attribute is not specified,
|key||Cache key value to use in the lookup. Policy expressions are allowed.||Yes||N/A|
|variable-name||Name of the context variable the looked up value will be assigned to, if lookup is successful. If lookup results in a miss, the variable will not be set. Policy expressions aren't allowed.||Yes||N/A|
- Policy sections: inbound, outbound, backend, on-error
- Policy scopes: global, workspace, product, API, operation
- Gateways: dedicated, consumption, self-hosted
<cache-lookup-value key="@("userprofile-" + context.Variables["enduserid"])" variable-name="userprofile" />
For more information and examples of this policy, see Custom caching in Azure API Management.
For more information about working with policies, see: