@Test
public void test2(){
ValueOperations<String, String> userOp = redisTemplate.opsForValue();
List<User> userList = userDAO.getUserByIds();
userOp.set("1234",CommonsUtil.returnNonNullObjectToJson(userList));
String retStr = userOp.get("1234");
JsonBinder jb = JsonBinder.buildNormalBinder();
JavaType javaType = jb.getCollectionType(ArrayList.class,User.class);
@SuppressWarnings("unchecked")
List<User> listUser = (List<User>) jb.getReadValue(retStr, javaType);
logger.info("size:"+ listUser.size());
for (User u : listUser) {
logger.info(u.getUsername());
}
}
Java redis demo List<User>
最新推荐文章于 2018-10-23 16:10:41 发布