caching through node js is not persisting data . My requirement is to add email ids as keys and string arrays as value again that keys. the bold line gives me null most of the time and it overwrites if i give new string. below are my codes.
var http = require('http');
var apigee = require('apigee-access');
var mcache = require('memory-cache');
http.createServer(function (request, response) {
var devemail = apigee.getVariable(request, 'developer.email');
var dataset = "welcome2018";
var Data = [];
var old = mcache.get(devemail);
var mkeys = _mcache.keys();
var oldval = _mcache.exportJson();
res = "mkeys:" + mkeys;
if (null !== devemail && null !== dataset) {
Data.push(dataset);
mcache.put(devemail, Data);
}
res = res + "\nuser email :" + devemail + ",\n" + "cachedatasets :" + mcache.get(devemail);
response.end(res) console.log(response);
}).listen(9001);, want to store email id as key and string array as value.On access of the same email id, value needs to be added in the string array.used 'memory-cache', and tried to put email id as key and string value in array, but it doesnt store the value in cache
for few seconds.Cache hits is always 0 my codes are like this: var http = require('http');
var apigee = require('apigee-access');
var mcache = require('memory-cache');
http.createServer(function (request, response) {
var devemail = apigee.getVariable(request, 'developer.email');
var Data = [];
var dataset = "welcome2018";
var Data = [];
var mkeys = _mcache.keys();
var oldval = _mcache.exportJson();
res = "mkeys:" + mkeys;
if (null !== devemail && null !== dataset) {
Data.push(dataset);
mcache.put(devemail, Data);
}
res = res + "\nuser email :" + devemail + ",\n" + "cachedatasets :" + mcache.get(devemail);
response.end(res) console.log(response);
}).listen(9001);