我有一个问题,EXEC 的回调随机返回一些值作为null
s.
该代码在大多数情况下都可以正常工作,但是它会随机失败(或者如果我反复刷新浏览器)...
这是代码减少到失败的程度:
var transaction = client.multi();
reply.forEach(function (id) { // reply always equals [ 'mykey1', 'mykey2' ]
transaction.hgetall(namespace + ":" + id);
});
transaction.exec(function (err, replies) {
// 'replies' sometimes returns all the responses properly,
// other times it returns some of the values as null
// See the examples I wrote below
});
当它工作正常时, exec 回调将返回:
[{
owner: '123',
id: 'asdasdasd',
name: 'asdasdasd',
created_at: '2012-10-06T09:26:25.596Z',
updated_at: '2012-10-06T09:28:54.929Z'
},
{
owner: '456',
id: 'asdfsdfasdf',
name: 'asdfsdfasdf',
created_at: '2012-10-06T09:27:19.251Z',
updated_at: '2012-10-06T09:28:03.116Z'
}]
当它不起作用时,它会返回:(注意null
值)
[{
owner: '123',
id: 'asdasdasd',
name: 'asdasdasd',
created_at: '2012-10-06T09:26:25.596Z',
updated_at: '2012-10-06T09:28:54.929Z'
}, null]