Closed Roiocam closed 3 months ago
redis cluster是不是不能很好的支持mget/mset?
redis cluster是不是不能很好的支持mget/mset?
这个不清楚,但是 JedisCluster 这个对象看起来是没有直接支持类似于 scan 那样多线程去拿的代码的,他的 mget 就是创建了一个:CommandObject, 里面有个 CommandArguments
最后在 ClusterCommandExecutor 里面这样执行的:
然后拿连接也是根据命令参数算出来 slot:
我思考的时候又想了下之前看 redis 源码的时候,Key 在不同的 SLOT 的时候,Redis Cluster 自身就会拒绝这个请求的:
我试了一下,JedisCluster 也确实体现了这一点:
ClusterCommandObjects clusterCommandObjects = new ClusterCommandObjects();
CommandObject<List<String>> mget = clusterCommandObjects.mget("a", "b", "c", "d");
System.out.println("mget");
Exception in thread "main" redis.clients.jedis.exceptions.JedisClusterOperationException: Keys must belong to same hashslot.
See: https://github.com/alibaba/jetcache/issues/865#issuecomment-2024561604
抽象了一下 pipeline 获取的接口,方便其他方法使用(getAll, delAll)