Skip to content
Create a gist now

Instantly share code, notes, and snippets.

@EGreg /DRY forked from fennb/gist:1124579
Created Jan 25, 2012

Asynchronous cache failover example
// asynchronous version
asynchronousCache.get("id:3244", function(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
} else {
// We have a thing from cache, do something with result
function doSomething(myThing) {
// gee that wasn't so hard, was it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.