I am new to APIGEE. I am trying to implement and a populate cache and lookup cache usecase.
From my test, I am not able to populate cache and lookup cache in subsequent request. However just for testing if I lookup cache within the same request I get a successful hit. So my setup is
Lookup cache → service callout → populate cache → lookup cache
The first lookup cache is always false and the second lookup cache is true for every request. My expectation is the first lookup cache should return a cache hit after the first request.
Can you please provide me guidance on what could be wrong.
First lookup
lookupcache.Lookup-Cache-1.cachekey vouchers__9344401449022lookupcache.Lookup-Cache-1.cachehit falselookupcache.Lookup-Cache-1.failed falselookupcache.Lookup-Cache-1.cachename woolworths__test__edr_customer_cachelookupcache.Lookup-Cache-1.assignto voucherjson
Second Lookup
lookupcache.Lookup-Cache-2.cachename woolworths__test__edr_customer_cachelookupcache.Lookup-Cache-2.assignto flowvarlookupcache.Lookup-Cache-2.cachekey vouchers__9344401449022lookupcache.Lookup-Cache-2.failed falselookupcache.Lookup-Cache-2.cachehit true
both lookup cache policy
<CacheKey>
<Prefix>vouchers</Prefix>
<KeyFragment ref="edrno"/>
</CacheKey>
<CacheResource>edr_customer_cache</CacheResource>
<Scope>Global</Scope>
EDIT
On further testing, I found that once in a while I get a valid cache hit on the first lookup. Approximately only 2 in 10 requests return “true” for cache hit. Does this mean something is wrong with the environment?
Here is the full configuration for the policies.
Thanks for helping out.
Lookup cache 1
<?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>
<FaultRules/>
<Properties/>
<CacheKey>
<Prefix>vouchers</Prefix>
<KeyFragment ref="edrno"/>
</CacheKey>
<CacheResource>edr_customer_cache</CacheResource>
<Scope>Global</Scope>
<AssignTo>voucherjson</AssignTo>
</LookupCache>
Lookup cache 2
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Lookup-Cache-2">
<DisplayName>Lookup Cache 2</DisplayName>
<FaultRules/>
<Properties/>
<CacheKey>
<Prefix>vouchers</Prefix>
<KeyFragment ref="edrno"/>
</CacheKey>
<CacheResource>edr_customer_cache</CacheResource>
<Scope>Global</Scope>
<AssignTo>flowvar</AssignTo>
</LookupCache>
Flow
<Flow name="getvouchers">
<Description/>
<Request>
<Step>
<FaultRules/>
<Name>Extract-edrno</Name>
</Step>
<Step>
<FaultRules/>
<Name>Lookup-Cache-1</Name>
</Step>
<Step>
<FaultRules/>
<Name>call-IDM</Name>
</Step>
<Step>
<FaultRules/>
<Name>Voucher-XML-to-JSON</Name>
</Step>
<Step>
<FaultRules/>
<Name>Populate-Cache-1</Name>
</Step>
<Step>
<FaultRules/>
<Name>Lookup-Cache-2</Name>
</Step>
</Request>
<Response>
<Step>
<FaultRules/>
<Name>Assign-Message-2</Name>
</Step>
</Response>
<Condition>(proxy.pathsuffix MatchesPath "/getvouchers/{edrno}") and (request.verb = "GET")</Condition>
</Flow>