0
votes

I am using lua script to do 2 operations belonging to same key. Running Redis in cluster mode. Using java jedis library to connect to the Redis cluster.

The syntax for loading lua script is as below

jedisCluster.loadScript(<ScriptString>, <Key>);

It returns a SHA value which I can use in evalsha function on jedis cluster as below

jedisCluster.evalsha(<ShaValue>, <Key Count>, <key>)

I am handling NoScript error when executing above method and will load the script again.

Question: If I am loading the same script with different key values will the SHA value is different? If the two keys land up in different cluster then the SHA value is different?

I am trying to save this SHA value in string use it for all keys.

I know the SHA of a string will be same but I am not sure if redis adding any extra information to the script before generating the SHA.

1

1 Answers

2
votes

The SHA1 sum of the script will always be the same for the same script (you can also compute it externally, e.g. using the sha1sum tool). This remains true in single-instance and cluster modes, regardless the number of keys and arguments that the script gets as input.