//首先注入redisTemplate
@Autowired
private RedisTemplate<String, Object> redisTemplate;//获取hash类型的ops
HashOperations<String, String, Object> stringObjectObjectHashOperations = redisTemplate.opsForHash();
//创建一个一个map并将一个对象的属性拆解进去
HashMap<String, Object> map = new HashMap<>();
map.put("username", user.getUsername());
map.put("password", user.getPassword());
map.put("tel", user.getTel());
map.put("address", user.getAddress());
map.put("imageFilename", user.getImageFilename());
map.put("email", user.getEmail());
map.put("coins", user.getCoins());
stringObjectObjectHashOperations.putAll(user.getId().toString(), map);
//为刚刚设置的key设置过期时间为6小时
redisTemplate.expire(user.getId().toString(), 6, TimeUnit.HOURS);