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
Add Script::load function #603
Conversation
Make it work the same in case of async and sync version. Potentially the old version was causing a infinite loop in case the redis is endlessly FLUSHed? Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
e9d3993
to
7538b31
Compare
Hi @djc as I see you've run the CI. |
95f2d67
to
36fee9d
Compare
Sorry..... *It must be it |
Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>
36fee9d
to
50a48b3
Compare
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, this mostly looks good!
} else { | ||
fail!(err); | ||
} | ||
let mut eval_cmd = cmd("EVALSHA"); |
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.
Why do you think we no longer need the loop
?
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.
As you may see that a sync and async implementation is different.
I think that the async implementation with 1 retry is better. So I replace a loop implementation with it.
The loop may cause a number of retries or even "potentially" an infinite loop.
See when there's no script LOAD
ed we load it, but then if someone FLUSH
es redis EVAL
will be an error an we will try to LOAD
the script one more time.
Also it's beneficial because the unification of the code.
|
||
let hash = script.prepare_invoke().load_async(&mut con); | ||
assert_eq!(hash, Ok(script.get_hash().to_string())); | ||
let mut con = ctx.multiplexed_async_connection_async_std().await.unwrap(); |
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.
Why did you change these to unwrap()
?
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.
To fix the build :) (I may mistaken but it was necessary to specify a Result::Err type)
Do you think it matters?
Hi there
This PR exposes a load function to not do it manually.
It also changes a repeat logic in sync version of
Script::invoke
to limit the repeat cycle to 2 attempts (The same way as is done in async version).Take care.