2

Currently I am having the below lua script local job_id = KEYS[1]; local job_body = KEYS[2]; if job_id ==nil or job_id == '' then error('Invalid job id') end; if job_body ==nil or job_body == '' then error('Invalid job body') end; redis.call('HSET','JOB:WORK_BODY',job_id,job_body);

which is called using jedis cluster implementation using evalsha something like: connection.evalsha(script, 2, jobId, jobBody)

This was working fine in normal redis but fails in cluster saying "JedisClusterOperationException: Keys must belong to same hashslot"

Documentation speaks about adding {} to the keys. But couldnt get where to and how to add in the above code.

Any help on this would be really helpful. Got stuck in this for a long time now.

Thanks in advance

GRS
  • 21
  • 1

1 Answers1

1

You should pass job_id and job_body as ARGV, instead of KEYS.

# script.lua
local job_id = ARGV[1]; local job_body = ARGV[2]

# other code

I'm not familiar with Jedis, but you can try the following code:

connection.evalsha(script, 1, "JOB:WORK_BODY", jobId, jobBody)

for_stack
  • 21,012
  • 4
  • 35
  • 48