java之redis使用管道pipeline实现批量新增和修改

redis使用管道pipeline实现批量新增和修改

解决方法:

1.核心方法http://www.yayihouse.com/yayishuwu/chapter/1669

2.使用方法

批量插入10条记录到redis的rd_table表中

 public static void main(String[] args) throws Exception{

    List<Map<String, String>> addList=new ArrayList<Map<String,String>>();

    for(int i=1;i<10;i++){

    HashMap<String, String> hashMap = new HashMap<String, String>();

hashMap.put("key"+i,"value"+i);

addList.add(hashMap);

    }

    if(addList.size()>0){

pipelineHmset(0, "rd_table", addList);

}

    }

猜你喜欢

转载自blog.csdn.net/qq_30908729/article/details/83819677