go-redis icon indicating copy to clipboard operation
go-redis copied to clipboard

Add RunLoad to script

Open simao opened this issue 2 years ago • 1 comments

Add new RunLoad method to Script. It tries to run the script using EvalSha, if that fails, it loads the script using SCRIPTLOAD and then tries again.

This is what the redis manual recommends libraries to do:

From https://redis.io/docs/manual/programmability/eval-intro/

In this case, the application should first load it with SCRIPT LOAD and then call EVALSHA once more to run the cached script by its SHA1 sum. Most of Redis' clients already provide utility APIs for doing that automatically. Please consult your client's documentation regarding the specific details

Please let me know if you think this should be merged, I will write some tests.

simao avatar May 22 '23 13:05 simao