About Redisson Lua Script Error

About Redisson Lua Script Error

這篇介紹Redisson Lua Script Error。

前情提要

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
使用Redisson套件執行一段Lua Script時,
報RedisException : redis() command arguments must
be strings or integers...等錯誤訊息。

經Trace後,問題是出在傳入的參數有缺少導致。
錯誤Example:
String key = "keyPoint";
String luaScript = " ... ";
int expireTime = 30000;
String value = "value";

RScript script = RedisManager.get().getScript(new StringCodec());

script.eval(RScript.Mode.READ_WRITE, luaScript, RScript.ReturnType.INTEGER,
Lists.newArrayList(key), expireTime);

value參數少傳進去而throw RedisException : redis() command arguments must
be strings or integers。

正確example:
String key = "keyPoint";
String luaScript = " ... ";
int expireTime = 30000;
String value = "value";

RScript script = RedisManager.get().getScript(new StringCodec());

script.eval(RScript.Mode.READ_WRITE, luaScript, RScript.ReturnType.INTEGER,
Lists.newArrayList(key), expireTime, value);