Working with cache in NodeJs

Not applicable

Hi Team,

I have populated/stored the cache using populatecache policy, now I want to retrieve the stored cache value using NodeJS. Below is some more information.

I have to develop the code to get cache in node.js, which should be equivalent to the below lookup cache policy.

<CacheKey>

<Prefix>sessionTime</Prefix>

<KeyFragment ref="sessiontoken"/>

</CacheKey>

<CacheResource>sessioncache</CacheResource>

<Scope>Global</Scope>

<AssignTo>sessionTimeCache</AssignTo>

Can some help me with the same kind of code using NodeJS to lookup the data.

Thanks,

Mula V V Reddy

0 5 505
5 REPLIES 5

You should be able to use the volos module to do this programmatically yourself or if you're open to using Apigee 127, you can see how you would implement an Apigee-backed cache here: https://github.com/apigee-127/a127-documentation/wiki/Quick-Start:-Add-Caching

Not applicable

You may also want to take a look at apigee-access, which is specific to Apigee Edge platform, and not as agnostic as Volos, which can leverage Redis or in memory.

@karl.kalckstein and @mvvbr - with the help of @Greg Brail and @sgopalam@apigee.com

the mystery has been solved. When getting the cache, you need to pass the scope. I was also banging my head trying to make it work. So, in your case you need to get cache as this:y

var cache = apigee.getCache(undefined, {resource:'Cache1', scope:'Global'});

Attached bundle contains a full example. nodeapptest2-rev1-2015-01-13.zip

Hope it helps!

BTW,

if you don't mention the scope, default scope will be set to exclusive.

Cache using volos as mentioned by @Jeremy Whitlock and apigee-access mentioned by @Diego Zuluaga works in the same way . They internally use the same logic.

Not applicable

The intention of getting cache in NodeJS is to add loop over it. If lookup cache policy is used, how to loop it. Any suggestion / solution for this?