zoukankan      html  css  js  c++  java
  • redis序列化和反序列化的操作-(以前咋操作我都忘记了)

    //拿到数据,redis如果有则将现在有的传进去,如果没有则获取接口
    ExWritPropertyVo ExWritPropertyVo = new ExWritPropertyVo();
    ExWritPropertyVo.setCaichanmingcheng("我是打电话的");
    ExWritPropertyVo.setCaichanmingchengType(21);
    byte[] serialize = SerializationUtils.serialize(ExWritPropertyVo);//lang3包下的
    redisTemplate.opsForValue().set("u",serialize);
    byte[] bs2 = (byte[]) redisTemplate.opsForValue().get("u");//redisTemplate
    ExWritPropertyVo deserialize = SerializationUtils.deserialize(bs2);
    System.out.println(deserialize);

    小案例:

        @GetMapping("/test01")
        public R test01(){
            byte[] bs2 = (byte[])redisTemplate.opsForValue().get("zhangsan");
            HashMap<String, String> ccxmapAll = new HashMap<String, String>(16);
    
            if(bs2!=null){
              ccxmapAll = SerializationUtils.deserialize(bs2);
            }
            if(ccxmapAll.size()<1){
                ccxmapAll.put("zhansgan","dasdsad");
                byte[] serialize = SerializationUtils.serialize(ccxmapAll);//lang3包下的
    
                redisTemplate.opsForValue().set("zhangsan",serialize);
           }
            return R.ok(ccxmapAll);
        }
    

      

  • 相关阅读:
    cf B. Number Busters
    hdu 5072 Coprime
    HDOJ迷宫城堡(判断强连通 tarjan算法)
    Entropy (huffman) 优先队列)
    Number Sequence
    Code (组合数)
    Round Numbers (排列组合)
    Naive and Silly Muggles (计算几何)
    SDUT 最短路径(二维SPFA)
    Pearls DP
  • 原文地址:https://www.cnblogs.com/q1359720840/p/14621197.html
Copyright © 2011-2022 走看看