Skip to content

Instantly share code, notes, and snippets.

@jkantr
Forked from hmpmarketing/gist:8c1891f81d316c8465146db3a0b7b723
Last active January 5, 2018 19:30
Show Gist options
  • Save jkantr/1e21d8d79df4c2a5520d9cfc9c239b53 to your computer and use it in GitHub Desktop.
Save jkantr/1e21d8d79df4c2a5520d9cfc9c239b53 to your computer and use it in GitHub Desktop.
// do this
cache.remember('key1', 600, function() {
return mysql.MobileAction.findOne({ where: {action_id: req.query.D} })
}).then((val) => {
console.log('set: ', val);
})
// don't do this
mysql.MobileAction.findOne({ where: {action_id: req.query.D} }).then(function(action) {
cache.remember('key1', 600, function() {
return Promise.resolve(action);
}).then((val) => {
console.log('set: ', val);
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment