Redis集群中的 CROSSSLOT Keys Error
场景 Redis单节点没有问题,切换到Redis Cluster后业务上某一功能出错: 1CROSSSLOT Keys in request don't hash to the same slot 出错的代码: 1var ctx = context.TODO() 2_, err := uq.queueImpl.rc.TxPipelined(ctx, func(pip redis.Pipeliner) error { 3 cmd := pip.LPush(ctx, uq.key, dest...) 4 if cmd.Err() != nil { 5 return cmd.Err() 6 } 7 return pip.SAdd(context.Background(), uq.setkey, dest...).Err() 8}) 这段代码的逻辑是向 list 中push一条数据,再向一个 set 加入数据,两步操作通过 pipline 在同一个事务中完成。 ...