Redis Cross Slot error

后端 未结 2 1133
囚心锁ツ
囚心锁ツ 2020-12-16 13:59

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 t

相关标签:
2条回答
  • 2020-12-16 14:27

    ERR CROSSSLOT Keys in request don't hash to the same slot

    As the error message suggests, only if all of the keys belong to same slot will the operation succeed. Otherwise, you will see this failure message. This error would be seen even though both/all slots belongs to the same node. The check is very strict and, as per the code, all keys should hash to same slot.

    0 讨论(0)
  • 2020-12-16 14:32

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

    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 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.

    You can force the keys to belong to the same node by using Hash Tags

    0 讨论(0)
提交回复
热议问题