Re:Node.js - A giant step backwards?
by brendoncrawford on Wednesday January 25, 2012 @04:47PM
(#3511898)
Or if you want more re-usability:
[ Parent
| on HN ]
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);
}
});
};