redis管道pipeline实现批量新增修改
解决方法:
dbIndex数据库的序号,key表名,keysmap键值数据集合
public static boolean pipelineHmset (int dbIndex,String key,Map<String, String> keysmap){
Jedis jedis = null;
try {
jedis = getJedis();
jedis.select(dbIndex);
Pipeline pip = jedis.pipelined();
//批量插入
pip.hmset(key, keysmap);
pip.sync();//同步
} catch (Exception e) {
logger_xt_err.info(e.getMessage());
e.printStackTrace();
}finally{
// 返还到连接池
if(jedis!=null)close(jedis);
}
return false;
}