Skip to content

Instantly share code, notes, and snippets.

@fletchowns
Created August 9, 2011 07:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fletchowns/1133565 to your computer and use it in GitHub Desktop.
Save fletchowns/1133565 to your computer and use it in GitHub Desktop.
function render() {
//do stuff
}
mcpool.acquire(function(mcpoolerr, mc) {
mc.get(cacheKey, function(mcgeterr, cachedResults) {
if (cachedResults == null) {
dbpool.acquire(function(dbpoolerr, db) {
db.query(
'select field from table where something = ? order by field limit 40',
[req.query.someValue],
function(error, queryResults, fields) {
dbpool.release(db);
mc.set(cacheKey, JSON.stringify(queryResults));
render(queryResults);
}
);
});
} else {
render(JSON.parse(cachedResults));
}
mcpool.release(mc);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment