Created
September 19, 2011 19:36
-
-
Save aaronblohowiak/1227358 to your computer and use it in GitHub Desktop.
suggested api for auto_sha
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
var redis = require("redis"), | |
client = redis.createClient(); | |
client.auto_sha = true; /* enable transparent sha1 cache and retry of all calls to eval */ | |
client.eval("return 1;", 0, function(err, num){..}); | |
/* checks client.auto_sha and will then look up sha in redis.sha1cache, | |
failing that will sha1 the script and cache it. | |
Perform the evalsha with an auto-fallback to eval if redis returns sha1 not found. | |
If the sha *is* found in redis.sha1cache, then just go ahead and call evalsha, | |
also falling back to eval if it is not found. | |
*/ | |
console.log(sys.inspect(redis.sha1cache)); | |
/* { "return 1":"EA42G..." }; | |
sha hash is per-process because the luascripts a program uses are expected to be limited. | |
if the user wants to stuff data into their luascript instead of passing it in as a ARG, | |
then they should have client.auto_sha = false; | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment