2 ms·
Don't forget to bubble errors up the callback chain along with return values (I always forget that too): getFromCache = function (id, query, callback) {
by davej 15y ago
Don't forget to bubble errors up the callback chain along with return values (I always forget that too):
getFromCache = function (id, query, callback) {
asynchronousCache.get(['id', id].join(':'), function(err, myThing) {
if (myThing == null) {
asynchronousDB.query(query, function(err, myThing) {
callback(err, myThing);
});
}
else {
callback(err, myThing);
}
});
};