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); }
---------------------------------------------------------------------------
国之殇,未敢忘!
南京大屠杀!
731部队!
以及核污染水排海等一系列全无人性的操作,购买他们的食品和为它们提供帮助只会更加变本加厉的害你,呼吁大家不要购买日本相关产品
昭昭前事,惕惕后人
吾辈当自强,方使国不受他人之侮!
---------------------------------------------------------------------------
作者:三号小玩家
出处:https://www.cnblogs.com/q1359720840/
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。 版权信息