I have a map data to cache in redis cluster using lua script in springboot project, such as:
{"demoKey:{1}":"value1","demoKey:{2}":"value2","demoKey:{3}":"value3"}
lua script like this:
local addMap = cjson.decode(ARGV[1]);for fieldKey, fieldValue in pairs(addMap) do redis.call("SET", fieldKey, fieldValue);end
JAVA CODE:
final DefaultRedisScript<?> redisScript = new DefaultRedisScript<>();redisScript.setScriptSource(LUA_SCRIPT);redisClient.execute(redisScript, new ArrayList<>(), JsonUtil.toString(addMap));
I have set the hash tag
in redis key, but I still get the exception while running the program.
org.springframework.data.redis.RedisSystemException: Error in execution; nested exception is io.lettuce.core.RedisCommandExecutionException: ERR Error running script (call to f_7cce57ffe5b0b94fa78680955c993e808ffa5f16): @user_script:7: @user_script: 7: Lua script attempted to access a non local key in a cluster node
Appreciating for any help.