Reputation: 43
I am new to Redis.Please find the below redis lua script using which returns value from using redis hmget command.I am doing a nil check.If the value is not nil return the value which is retrived from redis pcall else return none.
public static final String LOAD_PARAMS_LUA_SCRIPT = local jobType = redis.pcall('hmget',KEYS[1],KEYS[2]) if jobType ~= nil then return jobType else jobType = 'none' end;
I am invoking the lua script from java as below:
List<String> keys = Arrays.asList("1000.123","status");
List<String> args = Arrays.asList();
if(!this.connection.scriptExists(LOAD_PARAMS_LUA_SCRIPT)) {
this.connection.scriptLoad(LOAD_PARAMS_LUA_SCRIPT);
}
ArrayList<String> test = (ArrayList<String>)connection.eval(GET_BULK_JOB_PARAMS_LUA_SCRIPT, keys, args);
System.out.println("test:" + test);
Please let me know if am missing anything.The response which i get everytime is null.
Upvotes: 0
Views: 795