Accessing apigee cache via javascript policy

Hi Team,

I have an use case where apigee need to access the cache in apigee hybrid n number of cache key in a single transaction. 

The n varies from 1 to 10 . since it's dynamic count we wanted do lookup and populate cache via javascript or any other way which is available to do so. I am able see some references accessing via node js but I don't see any reference accessing java script. any syntax or reference would be helpful.

Thanks!

Solved Solved
0 2 395
1 ACCEPTED SOLUTION

Nope, you cannot do that directly. The LookupCache policy looks up a single item, a single key.  There's no way to look in the Apigee flow language. Sadly there's no way to directly access the Apigee cache from within the JavaScript policy either. 

If you have a need to do dynamic lookups in the way you described, then you may want to rely on your own cache. Like MemoryStore or your own Redis (you'll need to build an HTTP interface for that). 

Another option is to modify your key/value relationship.  It might be possible to collapse all the cached entries into one item, then use the JS step to fliter or select the items from the large cache payload. 

One final (maybe weird) option is to bundle the cache retrieval into an API Proxy, and then use the JS httpClient to make repeated calls to that other API proxy, in a loop.  

View solution in original post

2 REPLIES 2

Nope, you cannot do that directly. The LookupCache policy looks up a single item, a single key.  There's no way to look in the Apigee flow language. Sadly there's no way to directly access the Apigee cache from within the JavaScript policy either. 

If you have a need to do dynamic lookups in the way you described, then you may want to rely on your own cache. Like MemoryStore or your own Redis (you'll need to build an HTTP interface for that). 

Another option is to modify your key/value relationship.  It might be possible to collapse all the cached entries into one item, then use the JS step to fliter or select the items from the large cache payload. 

One final (maybe weird) option is to bundle the cache retrieval into an API Proxy, and then use the JS httpClient to make repeated calls to that other API proxy, in a loop.  

Thanks @dchiesa1. Thanks for all the options as well 🙂