Right. So I forgot about non blocking. The call to redis will enough time
for js to move on and execute down the page.
I had the feeling this was going to be embarrassing :)
On Monday, 8 June 2015 19:11:10 UTC+2, Aaron Reabow wrote:
>
> 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
> });
>
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/cba44014-a14a-45e2-88dc-cf1d422ddfa3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.