I have the feeling this might be really dumb. I am trying to obtain the value of a list's length from redis.
It is returning correctly inside the anonymous function (if I console.log it), I just can't for the life of me seem to access outside of that function.
Here I have set a local variable - len - and tried to assign a value for it inside the function.
I wouldn't expect it to work like this, because I should set a global variable len instead.
The strange thing is that neither approach works. Even if the global variable did the trick, it seems remiss to be using a global variable for something so trivial.
Any ideas on a solution? Here is my code:
var len = 0
redis.llen("chatRecord", function (err, length) {
log('length from llen is: ' + length)
len = length
});