Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
var stringify = require('json-stringify-date');
var obj = { d: new Date(2014, 2, 4) };
var s = stringify.stringify(obj);
if (s.indexOf('2014') >= 0) {
console.log('ok');
}
module.exports.addToCache = (key, value, callback) => {
if (!value) {
return setImmediate(() => callback());
}
module.exports.redis.multi().
lpush('mailtrain:cache:' + key, stringifyDate.stringify(value)).
expire('mailtrain:cache:' + key, 24 * 3600).
exec(err => callback(err));
};
module.exports.redis.rpop('mailtrain:cache:' + key, (err, value) => {
if (err) {
return callback(err);
}
try {
value = stringifyDate.parse(value);
} catch (E) {
return callback(E);
}
return callback(null, value);
});
};