I am creating a very simple client-server application using node.js and redis for the first time. After successfully starting my redis client and my http server, I try to do a simple SET / GET with my redis client.
First I do:
client.set('apple', 10, redis.print);
which returns Reply:Ok.
Immediately after that I do:
client.get('apple', function(err, reply) {
count = parseInt(reply);
return count;
});
Strange, when countI print, I get undefined. But if I use redis.print, for example:
client.get('apple', redis.print);
A Reply: 10returns to the console. 10also displayed if i do console.log(count).
I thought that maybe I used the given functions in the module incorrectly, but, having addressed both of them, I am not sure what causes my errors:
node_redis - github readme
API redis.io - GET
user1257724
source