Last active
October 8, 2015 21:30
-
-
Save avnersorek/48b5a98e954018abbdfc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 GetUser(userId, callback) { | |
redisClient.get(userId, function(redisError, redisResult){ | |
if (redisError !== null) callback(redisError, null); | |
else if (redisResult !== null) callback(null, redisResult); | |
else { | |
mysqlClient.getUser(userId, function(mysqlError, mysqlResult){ | |
if (mysqlError !== null) callback(mysqlError, null); | |
else callback(null, mysqlResult); | |
}); | |
} | |
}); | |
} | |
// usage : | |
GetUser('dnitems', function(error, user){ | |
if (error !== null) { | |
console.error('error', error); | |
} | |
else { | |
console.log('user', user); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment