-
Notifications
You must be signed in to change notification settings - Fork 33
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
Hardcode script hash values and deprecate cacheScripts #120
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/hash.ts
Outdated
await setHash(ctx, script, kind) | ||
console.log(" New script successfully loaded.") | ||
return await ctx.redis.evalsha(ctx.scriptHashes[kind]!, keys, args) | ||
console.log( |
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.
Do we really when these to be printed by default? Maybe we should have a debug config
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.
I removed the logs, but kept the warning below. Warning should never be logged, so if it does I think we can print by default #120 (comment)
|
||
console.log("Upstash Ratelimit: Script loaded successfully."); | ||
|
||
if (hash !== script.hash) { |
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.
This is the case where script itself it updated, but we haven't updated the constant script hash on sdk, right?
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.
no, because even if I update in the sdk, it will happen again in the next cold start.
This if condition should never be true though. It essentially means that the hashing algorithm of redis changed, which should never happen.
This is just a failsafe.
Previously, we had the cacheScripts parameter which allowed us to define the script running behavior of the sdk. The two options were:
cacheScripts: true
(defaul): load the script to redis on cold start. In the other runs, use the hash with EVALSHA command. Resulted in two round trips in cold start.2.
cacheScripts: false
: simply send the script with EVAL command. More bandwidth.Now, we deprecate the cacheScripts parameter. It no longer has any affect. We also change the two behaviors: