0

I'm new to Node JS and Redis and am having trouble understanding asynchronous operations with Redis. All I want to do in Node is get a list I have in the Redis DB and store it in a variable. This is the code I have (after establishing the connection):

var week_arr = client.lrange('week_list',0,-1, function(err, reply){
  console.log(reply);
});
console.log(week_arr);

This is the result I am getting on the console for this part: false, ['2015-12-18']. All I want to do is store that array (['2015-12-18']) inside the week_arr variable for later use.

Possible solution: I know that Redis is async. so do I have to store all my code inside this call back function until I am done using the reply (which is the week_list)?

shapiro
  • 131
  • 10

0 Answers0