在nodejs中通过键数组从redis集群获取值
Get values by array of keys from redis cluster in nodejs
我正在尝试通过键数组从 nodejs 中的 redis 集群获取值,
它 returns 错误:"All keys in the pipeline should belong to the same slot"
这是代码:
private GETALL_P(keys: string[], cb: any) {
var pipeline = this.client.pipeline();
keys.forEach(function (key: string, index: Number) {
pipeline.get(key);
});
pipeline.exec(function (err: any, result: any) {
cb(err, result);
});
}
我搜索了一下,有人说:它不适用于集群。
有什么办法吗?
redis集群上的多键操作需要在同一个节点上,这就是报错的原因。
要将所有必需的键强制到同一个节点,您可以使用 key hash tags,请记住,如果您对所有键执行此操作而不仅仅是某些子集,那么您正在使用一个毫无意义的集群。
我正在尝试通过键数组从 nodejs 中的 redis 集群获取值, 它 returns 错误:"All keys in the pipeline should belong to the same slot" 这是代码:
private GETALL_P(keys: string[], cb: any) {
var pipeline = this.client.pipeline();
keys.forEach(function (key: string, index: Number) {
pipeline.get(key);
});
pipeline.exec(function (err: any, result: any) {
cb(err, result);
});
}
我搜索了一下,有人说:它不适用于集群。 有什么办法吗?
redis集群上的多键操作需要在同一个节点上,这就是报错的原因。
要将所有必需的键强制到同一个节点,您可以使用 key hash tags,请记住,如果您对所有键执行此操作而不仅仅是某些子集,那么您正在使用一个毫无意义的集群。