标签:ops res 举例 message llb return redis redist exce
redisTemplate.execute(new RedisCallback() {
public Long doInRedis(RedisConnection connection) throws DataAccessException {
long result = 0;
result = connection.del(Key.getBytes());
return result;
}
});
//举例
// 从缓存中取验证码,根据用户名,是否与传入的匹配
final String Key = cus.getUsername() + "verificationCode";
Object strVerificationCode = redisTemplate.opsForValue().get(Key);
if (strVerificationCode == null)// 验证码没取到 {
message.setCode(ConstantUtil.M_DATA_EXPIRE);
message.setMessage("验证码已过期,请重新获取");
this.out(response, message); return;
}
if (!(strVerificationCode.equals(zipCode))) {
message.setCode(ConstantUtil.M_EXCEPTION);
message.setMessage("验证码错误");
this.out(response, message);
return;
} else {// 验证通过,删除验证码
redisTemplate.execute(new RedisCallback() {
public Long doInRedis(RedisConnection connection) throws DataAccessException {
long result = 0;
result = connection.del(Key.getBytes());
return result;
}
});
}
标签:ops res 举例 message llb return redis redist exce
原文地址:http://www.cnblogs.com/cuijinlong/p/6829965.html