gpt4 book ai didi

node.js - 在 Node.js 中从 Redis 中检索各种哈希值

转载 作者:IT王子 更新时间:2023-10-29 05:57:49 25 4
gpt4 key购买 nike

如何通过 node-redis 在 Node.js 中从 Redis 检索各种哈希值? ?检索各种哈希值的最佳方法似乎是 pipelines但我还没有找到如何在 Node 中使用它们。

最佳答案

您可以使用 multi 命令对哈希检索命令进行排队:

var redis  = require("redis"),
client = redis.createClient(),
multi_queue;

multi_queue = client.multi();
...
for (key in keys) {
multi_queue.hgetall(key);
}

multi_queue.exec(function (err, replies) {
console.log("MULTI got " + replies.length + " replies");
replies.forEach(function (reply, index) {
console.log("Reply " + index + ": " + reply.toString());
});
});

关于node.js - 在 Node.js 中从 Redis 中检索各种哈希值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8578790/

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