Created
August 9, 2011 07:51
-
-
Save fletchowns/1133565 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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