gpt4 book ai didi

node.js - 如何理解node_redis中的参数?

转载 作者:可可西里 更新时间:2023-11-01 11:13:53 25 4
gpt4 key购买 nike

全部

我正在研究node_redis,在examples/simple.js中,有如下代码:

1    client.hset("hash key", "hashtest 1", "some value", redis.print);
2 client.hset(["hash key", "hashtest 2", "some other value"], redis.print);
3 client.hkeys("hash key", function (err, replies) {
4 console.log(replies.length + " replies:");
5 replies.forEach(function (reply, i) {
...

我很困惑:

为什么第 3 行有两个参数 "(err, replies)",设计者定义了多少个参数?

或者你想指导我应该阅读什么书或其他东西来理解它们?提前致谢!

最好的问候

彭朝泽

最佳答案

function (error, data..) 是 node.js 中回调参数的实际标准。

如果操作成功完成,error 为 null,replies 为带有散列键的数组。如果有错误,错误包含详细信息并且不填写回复。

你问的是这个吗?

关于node.js - 如何理解node_redis中的参数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14390569/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com