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";

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM