// 1. 生成一个32位的唯一令牌(无横线UUID)
String key = UUID.fastUUID().toString(true);
// 2. 获取Redis中存储手机认证信息的键名
String redisKey = RedisKey.getPhoneAuthKey(appUser.getId());
// 3. 将令牌存入Redis,有效期600秒(10分钟)
ServiceHolder.holder.redisUtils.set(redisKey, key, 600);
RedisKey:
private static final String USER_PHONE_TEMP_AUTH_KEY="app:user:phoneauth:";
public static String getPhoneAuthKey(String userId){
return USER_PHONE_TEMP_AUTH_KEY+userId;
}