3 ms·
Use recursion. Fixed: asynchronousCache.get("id:3244", function doThing(err, myThing) { if (myThing === null) { asynchronousDB.query("SELECT * fro
by MatthewPhillips 15y ago
Use recursion. Fixed:
asynchronousCache.get("id:3244", function doThing(err, myThing) {
if (myThing === null) {
asynchronousDB.query("SELECT * from something WHERE id = 3244", function(err, myThing) {
// We now have a thing from DB, do something with result
doThing(err, myThing);
});
return;
} else if(err !== null) {
// Handle error.
return;
}
// We have a thing.
});
- CoffeeDregs 15y agoWere you implying that your solution was simpler?