首页 > 编程语言 > 详细

java Redis读取数据方法

时间:2018-05-11 19:55:21      阅读:325      评论:0      收藏:0      [点我收藏+]

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

}

java Redis读取数据方法

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!