Take the data from redis and convert it into java object

1. Redis takes out the data and converts it to UserEntity

 


// Data is stored in redis

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


// Get data and turn it into user entity

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

Guess you like

Origin www.cnblogs.com/gpxs/p/12709786.html