ShardedJedisPool是如何选择对应的库的? 10
redis一般实例可以用select整形来选择对应的分库,ShardedJedisPool该怎么选择分库?网上看了没有对应的资料,有大神解答吗?...
redis一般实例可以用select 整形 来选择对应的分库,ShardedJedisPool该怎么选择分库?网上看了没有对应的资料,有大神解答吗?
展开
1个回答
展开全部
Collection<Jedis> collection=shardedJedis.getAllShards();
Iterator<Jedis> jedis = collection.iterator();
while(jedis.hasNext()){
jedis.next().select(redisIndex);
}
ShardedJedisPipeline pipeline = shardedJedis.pipelined();
if (fields.length > 0) {
for (int i = 0; i < fields.length; i++) {
pipeline.hset(key,fields[i],values[i]);
}
pipeline.sync();
}
Iterator<Jedis> jedis = collection.iterator();
while(jedis.hasNext()){
jedis.next().select(redisIndex);
}
ShardedJedisPipeline pipeline = shardedJedis.pipelined();
if (fields.length > 0) {
for (int i = 0; i < fields.length; i++) {
pipeline.hset(key,fields[i],values[i]);
}
pipeline.sync();
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询