Skip to content

Instantly share code, notes, and snippets.

@aaronblohowiak
Created September 19, 2011 19:36
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 aaronblohowiak/1227358 to your computer and use it in GitHub Desktop.
Save aaronblohowiak/1227358 to your computer and use it in GitHub Desktop.
suggested api for auto_sha
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