Redis 跨槽错误 [英] Redis Cross Slot error

查看:28
本文介绍了Redis 跨槽错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Redis 上一次插入多个键/值(有些值是集合,有些是散列),但出现此错误:ERR CROSSSLOT 请求中的键未散列到同一个槽

I am trying to insert multiple key/values at once on Redis (some values are sets, some are hashes) and I get this error: ERR CROSSSLOT Keys in request don't hash to the same slot.

我不是从 redis-cli 这样做,而是从一些需要将多个键/值写入 redis 集群的 Go 代码中这样做.我看到代码中的其他地方以这种方式完成了多个键值,但我不明白为什么我的不起作用.没有这个错误的哈希要求是什么?

I'm not doing this from redis-cli but from some Go code that needs to write multiple key/values to a redis cluster. I see other places in the code where multiple key values are done this way and I don't understand why mine don't work. What are the hash requirements to not have this error?

谢谢

推荐答案

在集群拓扑中,键空间被划分为哈希槽.不同的节点将持有哈希槽的子集.

In a cluster topology, the keyspace is divided into hash slots. Different nodes will hold a subset of hash slots.

多键操作、交易或涉及多个键的 Lua 脚本仅在所有涉及的键都在属于同一节点的哈希槽中时才被允许.

Multiple keys operations, transactions, or Lua scripts involving multiple keys are allowed only if all the keys involved are in hash slots belonging to the same node.

Redis Cluster 实现了所有可用的单键命令Redis 的非分布式版本.执行复杂的命令像集合类型联合或交集这样的多键操作是只要键都属于同一个节点就可以实现.

Redis Cluster implements all the single key commands available in the non-distributed version of Redis. Commands performing complex multi-key operations like Set type unions or intersections are implemented as well as long as the keys all belong to the same node.

您可以使用哈希标签

这篇关于Redis 跨槽错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆