Exclusive scope not working for LookupCache and PopulateCache

Hi,

I've been working on a simple caching example where I am using LookupCache in the request

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache async="false" continueOnError="false" enabled="true" name="Lookup-Cache">
    <DisplayName>Lookup Cache</DisplayName>
    <CacheKey>
        <KeyFragment ref="request.queryparam.page"/>
    </CacheKey>
    <Scope>Exclusive</Scope>
    <AssignTo>cached.response</AssignTo>
</LookupCache>

and PopulateCache in the response

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache async="false" continueOnError="false" enabled="true" name="Populate-Cache">
    <DisplayName>Populate Cache</DisplayName>
    <CacheKey>
        <KeyFragment ref="request.queryparam.page"/>
    </CacheKey>
    <Scope>Exclusive</Scope>
    <ExpirySettings>
        <TimeoutInSec>3600</TimeoutInSec>
    </ExpirySettings>
    <Source>response.content</Source>
</PopulateCache>

This works fine if I use Scope as Global or Proxy. But if I change the scope to Application or Exclusive then it fails. That is the LookupCache always ends up with a miss.

Any pointers?

Solved Solved
0 1 193
1 ACCEPTED SOLUTION

In time, I realized that LookupCache does not lead to a hit on being invoked immediately after a request leading to PopulateCache was made. It takes some time for entries added via PopulateCache to be available for LookupCache. The number of MPs that you have probably also come into play. Detailed info: https://docs.apigee.com/api-platform/cache/cache-internals.html

View solution in original post

1 REPLY 1

In time, I realized that LookupCache does not lead to a hit on being invoked immediately after a request leading to PopulateCache was made. It takes some time for entries added via PopulateCache to be available for LookupCache. The number of MPs that you have probably also come into play. Detailed info: https://docs.apigee.com/api-platform/cache/cache-internals.html