Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

print cache key in APIGEE x

Hi Team,

I am having 2 proxies where cachekey I want to print in different proxy : I have populate cache policy attached in another proxy and lookup I am using in another proxy , is it possible to print :

populate cache policy (proxy1) : 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PopulateCache continueOnError="false" enabled="true" name="PC-Store-Secondary-Session-Token">
<DisplayName>PC-Store-Secondary-Session-Token</DisplayName>
<CacheResource>xxx-Secondary-Token</CacheResource>
<Source>access_token</Source>
<Scope>Application</Scope>
<CacheKey>
<KeyFragment>cached_token</KeyFragment>
</CacheKey>
<ExpirySettings>
<!-- 119 minutes -->
<TimeoutInSeconds>7140</TimeoutInSeconds>
</ExpirySettings>
</PopulateCache>
 
lookup cache in proxy 2 : 
 
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<LookupCache continueOnError="true" enabled="true" name="LC-RetrieveCachedValue">
<DisplayName>Retrieve Cached Value</DisplayName>
<CacheResource>xxx-Secondary-Token</CacheResource>
<Scope>Application</Scope>
<AssignTo>retrieved_cache_value</AssignTo>
<CacheKey>
<KeyFragment ref="requested_cache_key"/>
</CacheKey>
</LookupCache>
 
requested_cache_key this I am sending as queryparam and the value is : cached_token but always I am getting cachehit false , kind,ly guide if possible
 
0 3 98
3 REPLIES 3

Your use case of using 2 different proxies will not work with Scope set to "Application" as per the docs: https://cloud.google.com/apigee/docs/api-platform/reference/policies/populate-cache-policy#scopeelem...

You should use Scope of "Global" to share across proxies.

Thank you, @kurtkanaskie . I have a small clarification: If I use the global keyword, do I need to use it for both proxies? Additionally, regarding the cache name and cache key for for 2nd proxy  should the format be something like apifactory__test__apiAccessToken? 

I think if you just change the Scope to "Global" and ensure the CacheKey/KeyFragment value is the same in both proxies and policies it should work, but I've not tested it.