java Redis读取数据方法

1.

    public Map<String, List<CellInfo1>> getSceneCoverCellForRedis(){
        Jedis jedis = null;
        Map<String, List<CellInfo1>> cellMap= null;
        try {
            jedis = jedisPool.getResource();
            String jsonStr= jedis.get(DbKeys.WB_COVERAREA_4);
            Type type = new TypeToken<Map<String,List<CellInfo1>>>() {}.getType(); 
            Gson gson = new Gson();
            cellMap= gson.fromJson(jsonStr,type);
            jedis.close();
            jedis= null;
        } catch (Exception e) {
            if(jedis != null){
                jedis.close();
            }
            e.printStackTrace();
        }
        return cellMap;
    }

2.

public class DbKeys {

......

public final static String WB_COVERAREA_4="wb_coverarea_4";

}

原文地址:https://www.cnblogs.com/baixiuhua/p/9025555.html