LookupCache Policy does not work on next request

Not applicable

Hi, When i populate a cache in one request and lookup the value from a second request, the cache is not returning my value, here is the detail...

I have two proxy endpoints "/test1" and "/test2",

"/test1" has this flow....

use JS to set two variables,

populate the cache with the key/value from the js variables,

lookup the value for the same key.

This works perfectly.

"/test2" has this flow... use JS to set two variables,

lookup the value for the same key,

this does not work when calling "/test1" then "/test2" directly afterwards

Here is my JS policy used on both...

context.setVariable('myscope.myvariable', "1");
context.setVariable('myscope.mycachekey', "abc");

Here is my populate cache policy used in "/test1"

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache async="false" continueOnError="false" enabled="true" name="Populate-Test-Cache">
    <DisplayName>Populate Test Cache</DisplayName>
    <Source>myscope.myvariable</Source>
    <CacheResource>test</CacheResource>
    <CacheKey>
        <KeyFragment ref="myscope.mycachekey"/>
    </CacheKey>
    <Scope>Global</Scope>
    <ExpirySettings>
        <TimeoutInSec>99999</TimeoutInSec>
    </ExpirySettings>
</PopulateCache>

And Here is my lookup cache policy used in both

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Lookup-Cache-Test-1">
    <DisplayName>Lookup Cache Test 1</DisplayName>
    <CacheResource>test</CacheResource>
    <Properties/>
    <CacheKey>
        <KeyFragment ref="myscope.mycachekey"/>
    </CacheKey>
    <Scope>Global</Scope>
    <AssignTo>myscope.cachedvariable</AssignTo>
</LookupCache>

The result is that when i...

GET to "test1" i can see "myscope.cachedvariable" is set to 1 after the lookup

GET to "test2" i cannot see "myscope.cachedvariable" cachehit is set to false

I can see that the cachekey used in both lookups is "myorgtest__dev____abc"

Any ideas why this might not be working?

Solved Solved
2 7 447
1 ACCEPTED SOLUTION

Not applicable

Hi, so thanks for the reply..... I have found an answer.... do not trust the TRACE tool. instead of looking at the value of "cachehit" in the trace tool which is incredibly unreliable, i just wrote my "myscope.cachedvariable" to the response, once i tested this i could see it was always working, it was just the TRACE tool telling me it hadn't set the variable value.

View solution in original post

7 REPLIES 7

Dear @shawn.hepworth , Welcome to Apigee Community 🙂

Dear @shawn.hepworth ,

It does work for me. Please find attached proxies. I haven't used separate cache resource. I have used shared resource. I can able to cache value using proxy 1 & retrieve same in proxy 2.

1600-screen-shot-2015-12-03-at-81007-pm.png

weather1-rev2-2015-12-03.zipweather2-rev1-2015-12-03.zip

Keep us posted

Not applicable

Hi, so thanks for the reply..... I have found an answer.... do not trust the TRACE tool. instead of looking at the value of "cachehit" in the trace tool which is incredibly unreliable, i just wrote my "myscope.cachedvariable" to the response, once i tested this i could see it was always working, it was just the TRACE tool telling me it hadn't set the variable value.

@shawn.hepworth, Glad issue is resolved 🙂

Thanks for sharing how you resolved it. And welcome @shawn.hepworth! 🙂

Strange - it works for me. I can examine {{lookupcache.LookupCache-1.cachehit}} and it is true if the LookupCache succeeded, and false if no hit.

@Dino , Agree with you, Even it works for me too. @shawn.hepworth , Can you please provide us more details if you still see an issue with trace tool ?