I'm writing a script in node.js, using scripto, and I'm trying to do a nil check to a value from the database: here is the js code (for node)-
var redis = require("redis");
var redisClient = redis.createClient("6379","localhost");
var Scripto = require('redis-scripto');
var scriptManager = new Scripto(redisClient);
var scripts = {
'test':'local function test(i) '+
'if (i==nil) then return i end '+
'local ch = redis.call("get", i) '+
'if (ch==nil) then return ("ch is nil") '+
'else return "1" '+
'end end '+
'return (test(KEYS[1]))',
};
scriptManager.load(scripts);
scriptManager.run('test', ["someInvalidKey"], [], function(err,result){
console.log(err || result);
});
but I can't get into "ch is nil" in the if statement... any help ??