3.7.7、redis__Java将数据写入redis中存储,java操作redis

使用Java语言将数据读取再写入redis数据库中存储

public class Demo07 {
    public static void main(String[] args) throws Exception{
        Jedis jedis = new Jedis("master", 6379);
        BufferedReader br = new BufferedReader(
                new FileReader("D:\\Program Files\\IDEA\\IdeaProject\\shujiabigdata\\data\\student.txt"));
        String line;
        while ((line=br.readLine())!=null){
            String[] split = line.split(",");
            String id = split[0];
            String name = split[1];
            String age = split[2];
            String sex = split[3];
            String clazz = split[4];
            HashMap<String, String> map = new HashMap<>();
            map.put("id",id);
            map.put("name",name);
            map.put("age",age);
            map.put("sex",sex);
            map.put("clazz",clazz);
            jedis.hmset("student:"+id,map);
        }
    br.close();
    }
}
上一篇:YOLOV5:数据集制作


下一篇:jmeter参数传入2种方式