Can I query KVM, caches via apigee-access npm module across environments from a single environment?

Hello Team,

A brief background: I am working on a chat-bot like interface (via Hipchat/Slack kind of messaging interactions). I would like to offer commands like /cache {env}({cache-key}) and /vault {env}({entry-key}) for the operations teams. This would make their life a bit easier than pulling out the big guns (management APIs) every time.

Looking through the npm module (apigee-access), I am able to query from the cache/vault/kvm from the current environment only, not across environments. Can these node-js functions be enhanced to accept an optional environment argument, so I can build a generic interface? Any other ideas/suggestions or alternatives?

Thanks,

Girish

0 2 161
2 REPLIES 2

Hi @Girish Gajria,

It is possible to manage the cache in different environments using the apigee-access module. The best way to do this, is to build the cache key yourself. You can run a trace when using the PopulateCache policy to see exactly what the generated key looks like, but it will be something like this...

orgName__envName__apiProxyName__deployedRevisionNumber__proxy|TargetName__cachePrefixcacheKey

You can then retrieve a value from a different environment by changing the envName. Alternatively, if you are exclusively managing the cache from Node JS, you can use any Cache Key you want.

NOTE

As youve said, it is rarely a good idea to call the Management APIs during runtime traffic. The reason being that normal API traffic is processed by a component called the Message Processor. This is designed to handle large amounts of traffic. Management API calls are handled by a different component called the Management Sever. This is designed to do some heavy lifting (deployments, creation of environment entities, user management etc.), however is not design to handle high volumes. For example, we would never expect to deploy API proxies at 100 transactions per second.

For the absolute best performance I would recommend the following:

- Use Apigee out of the box policies where possible. They are the fastest way to complete any task in Edge.

- Use Organization level KVMs where required, and access them via policy: http://docs.apigee.com/api/keyvalue-maps

- If you absolutely need to be sharing a cache across environments, then use Apigee-Access.

Hope this helps!

Thanks @Sean Davis for the detailed answer. I am working with the npm cache functions like apigee.getCache(..) and cache.get(..) functions.

var cache = apigee.getCache(cacheResource, {scope: 'global',env:'dev/test/prod/etc'}); //can I add an env property here, dynamically as indicated here??
cache.get(cacheKey, function(err, data){ //so when I do this, it should hit the specified env level cache rather than the env where it is currently invoked from

Currently my caches are populated and fetched via the npm module itself. But my issue is if my app is deployed on dev then only the dev env is hit. Though organization level cache might work but as you suggest may not be prod-grade code

Hope my query makes sense!

Thanks,

Girish