var http = require('http'); var apigee = require('apigee-access'); var cache = apigee.getCache('myprojcache', {scope: 'global'}); //var cache = apigee.getCache(); var svr = http.createServer(function(req, resp) { cache.get('testkey', function(err, data) { // err is "Invalid Cached Data" (2nd and subsequent invocations of API) // err is undefined, when we don't expect to have data in cache (1st invocation of API) resp.end('response from cache: ' + err + ' '+ data); if (!data) { cache.put('testkey', 'testval', 60, function(err) { console.log('cache put has errors? ', err); }); } }); }); svr.listen(9000, function() { console.log('Node HTTP server is listening'); });