Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Cache data with lua script, but getting RedisCommandExecutionException with accessing a non local key in a cluster node

$
0
0

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.


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>