Is there a way to extract cache key generated by Lookup-Cache-policy

The Look-up-cache policy docs mention about how to generate a custom cache key by combining various key fragments. But is it possible to store the generated cache-key into some variable or extract using Extract Variable policy?

I would like to use the generated cache key in a JavaScript policy and pass it as a request variable to use it later in a separate proxy.

Solved Solved
1 2 336
1 ACCEPTED SOLUTION

By default the Lookup-Cache Policy will generate various flow variables and

lookupcache.Lookup-Cache-1.cachekey is one of them.
lookupcache.<lookup-cache-policy-name>.cachekey

You can use this variable in other policies.

For this policy, the generated cache key will be,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Lookup-Cache-1">
    <DisplayName>Lookup Cache-1</DisplayName>
    <Properties/>
    <AssignTo>twitter-translate.apiAccessToken</AssignTo>
    <!-- An enumeration representing a prefix for namespace scope. -->
    <Scope>Exclusive</Scope>
    <!-- The unique pointer (a flow variable value) that was used to store the data in the cache. -->
    <CacheKey>
        <KeyFragment>apiAccessToken</KeyFragment>
        <KeyFragment ref="request.header.user-agent"/>
    </CacheKey>
</LookupCache>
{org_name}__{env}__{proxy-name}__{virtual-host}__apiAccessToken__Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

View solution in original post

2 REPLIES 2

By default the Lookup-Cache Policy will generate various flow variables and

lookupcache.Lookup-Cache-1.cachekey is one of them.
lookupcache.<lookup-cache-policy-name>.cachekey

You can use this variable in other policies.

For this policy, the generated cache key will be,

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Lookup-Cache-1">
    <DisplayName>Lookup Cache-1</DisplayName>
    <Properties/>
    <AssignTo>twitter-translate.apiAccessToken</AssignTo>
    <!-- An enumeration representing a prefix for namespace scope. -->
    <Scope>Exclusive</Scope>
    <!-- The unique pointer (a flow variable value) that was used to store the data in the cache. -->
    <CacheKey>
        <KeyFragment>apiAccessToken</KeyFragment>
        <KeyFragment ref="request.header.user-agent"/>
    </CacheKey>
</LookupCache>
{org_name}__{env}__{proxy-name}__{virtual-host}__apiAccessToken__Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36

Thank you Siddharth. I tried reading the flow vaiable in a Assign message policy and it populated the variable, provided the Lookup-policy was executed. I actually need to use the key even when Lookup policy did not execute. I think I may need to manually create the key again for my use case.