Map里面放数据,然后再把map放到list中,在把list转换成json,然后再把json存到map里面,最后使用Hash Key的方式,存入到redis中

部分代码如下:

                                    map.put("busiName", busiList.get(q).getAppname());
                                    map.put("projectName", projectList.get(w).getEngname());
                                    map.put("userList", ((list1.toString()).replace("[", "")).replace("]", ""));
                                    map.put("allCost", totalCost);
                                    map.put("storageCost", hbaseCost + hdfsCost);
                                    map.put("calculationCost", yarnCost);
                                    
                                    // 流成本
                                     map.put("liuCost", "0");
                                     
                                    if (costing > 0) {
                                        map.put("proportionCost", totalCost / costing * 100);
                                    } else {
                                        map.put("proportionCost", "0");
                                    }

                                  //map放到list里面
                                    list.add(map);
                                }
                            }
                            try {
                                
                                String redisid = redis_ip;
                                String redisport = redis_port;
                                Jedis jedis = new Jedis(redisid, Integer.valueOf(redisport));

                                //list转成json格式
                                String json = JSONObject.toJSONString(list); 
                                Map<String, String> bigmap = new HashMap<String, String>();

                                 //json放在map里面,然后通过Hash Key的方式,存入到redis中
                                bigmap.put(groupName,json);
                                jedis.hmset("groupName", bigmap);
                                jedis.close();

猜你喜欢

转载自blog.csdn.net/xiaoyutongxue6/article/details/81949931
今日推荐