首页 新闻 搜索 专区 学院

ShardedJedis 分布式连接池调用是怎么选择DB的,就是选择哪个数据库

0
悬赏园豆:10 [已解决问题] 解决于 2015-06-16 11:14

分布式连接池调用是怎么选择DB的?看下面代码中都没发现是怎么选库的,如果是选择的默认,那么哪里可以指定一个DB?
public void test8shardPipelinedPool() {
ShardedJedis>

ShardedJedisPipeline pipeline = one.pipelined();

long start = System.currentTimeMillis();
for (int i = 0; i < 100000; i++) {
pipeline.set("sppn" + i, "n" + i);
}
List<Object> results = pipeline.syncAndReturnAll();
long end = System.currentTimeMillis();
pool.returnResource(one);
System.out.println("Pipelined@Pool SET: " + ((end - start) / 1000.0)
+ " seconds");
}

kingcsking的主页 kingcsking | 初学一级 | 园豆:197
提问于:2015-05-19 09:24
< >
分享
最佳答案
0

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();
}

kingcsking | 初学一级 |园豆:197 | 2015-06-16 11:14
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册