希望有人可以协助node-redis上的(简单)异步问题。我试图从redis db中的一个散列加载一个集合,然后再使用这个集合集合。下面的代码片段: -node.js redis异步查询
var redis_client = redis.createClient(REDIS_PORT, REDIS_URL);
redis_client.hgetall(target_hash,function(e,o){
Object.keys(o).forEach(function(target){
// get the "name" from the hash
redis_client.hget(o[target],"name",function(e,o){
if (e){
console.log("Error occurred getting key: " + e);
}
else {
redis_client.sadd("newset",o);
}
});
});
// the following line prints nothing - why ??
redis_client.smembers("newset",redis.print);
当我审视“newset”的预期被填充Redis的内容,但在运行时,它显示为空。我确定这是一个异步问题 - 任何帮助非常感谢!
一个幽默的比喻与异步问题的时候,这将有助于你 - https://groups.google.com/forum/ #!MSG /谷歌的Web的工具包/ -soVdfMGug8/vRmqIcAZ5zsJ – 2012-04-18 14:47:02