-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use evalsha for scripts #77
Conversation
@mike-marcacci can you please look at this PR? |
redlock.js
Outdated
return server.evalsha(script.hash, args, (err, result) => { | ||
if(err !== null && err.message.startsWith("NOSCRIPT")) { | ||
// load the script, but don't wait for it, on the next call it will be available | ||
server.script('load', script.value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you call regular eval
later you don't need to call load
, as it automatically caches the script.
https://redis.io/commands/eval#script-cache-semantics
Executed scripts are guaranteed to be in the script cache of a given execution of a Redis instance forever. This means that if an EVAL is performed against a Redis instance all the subsequent EVALSHA calls will succeed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, fixed.
Lazy loading the scripts: trying with evalsha if it fails on “NO SCRIPT” we will load the script (using eval) so next run will have evalsha.
@mike-marcacci can you please CR this PR? |
@mike-marcacci if you can, please look at this PR :) |
Sorry for the delay - it's been a busy year 😬 Hoping to cut a new release shortly. |
@mike-marcacci thanks a lot, totally understandable :) |
Lazy loading the scripts: trying with evalsha if it fails on “NO SCRIPT” we will run eval (which will load the script) and next call will use evalsha.
#76