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

标签 node.js redis node-redis

全部

我正在研究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/

相关文章:

node.js - 从命令行调用nodejs脚本不起作用

node.js - Node Js 链接响应

python - 使用 Docker 部署 Django channel

node.js - 如何将 node.js 中的管道传输到 redis?

node.js - 最大限度减少实时连接延迟的技术

ruby-on-rails - Sidekiq Redis::CannotConnectError:在生产环境中连接到 127.0.0.1:6379 上的 Redis 时出错

node.js - 为什么我的代码每次运行我的 node.js 应用程序时都会打印不合逻辑的模式?

Redis发布编码数据

node.js - 这是重用 redis 客户端的正确方法吗?

javascript - 在 Javascript 中分配变量