Skip to content

Latest commit

 

History

History
68 lines (45 loc) · 3.8 KB

cache-lookup-value-policy.md

File metadata and controls

68 lines (45 loc) · 3.8 KB
titledescriptionservicesauthorms.servicems.topicms.datems.author
Azure API Management policy reference - cache-lookup-value | Microsoft Docs
Reference for the cache-lookup-value policy available for use in Azure API Management. Provides policy usage, settings, and examples.
api-management
dlepow
azure-api-management
reference
07/23/2024
danlep

Get value from cache

[!INCLUDE api-management-availability-all-tiers]

Use the 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.

Note

This policy must have a corresponding Store value in cache policy.

[!INCLUDE api-management-cache-volatile]

[!INCLUDE api-management-policy-generic-alert]

Policy statement

<cache-lookup-valuekey="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" />

Attributes

AttributeDescriptionRequiredDefault
caching-typeChoose between the following values of the attribute:
- internal to use the built-in API Management cache,
- external to use the external cache as described in Use an external Azure Cache for Redis in Azure API Management,
- prefer-external to use external cache if configured or internal cache otherwise.

Policy expressions aren't allowed.
Noprefer-external
default-valueA value that will be assigned to the variable if the cache key lookup resulted in a miss. If this attribute is not specified, null is assigned. Policy expressions are allowed.Nonull
keyCache key value to use in the lookup. Policy expressions are allowed.YesN/A
variable-nameName 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.YesN/A

Usage

Example

<cache-lookup-valuekey="@("userprofile-" + context.Variables["enduserid"])"variable-name="userprofile" />

For more information and examples of this policy, see Custom caching in Azure API Management.

Related policies

[!INCLUDE api-management-policy-ref-next-steps]

close