从redis中取出数据并转成java对象

1.redis取出数据转成UserEntity


//数据存入redis中

redisTemplate.opsForValue().set(loginame, JSON.toJSONString(users),1000,TimeUnit.SECONDS);


//获取数据并转成用户实体

String userJson = (String) redisTemplate.opsForValue().get("loginame");
UserEntity user = (UserEntity) JSONArray.parseArray(userJson, UserEntity.class);

猜你喜欢

转载自www.cnblogs.com/gpxs/p/12709786.html
今日推荐