/**
* 延迟10秒钟
* @param phone
* @return
*/
@Override
public Object delay(final String phone){
String redisKey = "SMS_LIMIT_"+phone;
ValueOperations<Serializable, Object> operations = redisTemplate.opsForValue();
Long count = operations.increment(redisKey,1);
if (count == 1){
redisTemplate.expire(redisKey,10,TimeUnit.SECONDS);
}
if (count >1){
return "10秒内只能操作一次";
}
/**
* 可以用来发短信等操作
*/
this.set(phone,"bbb");
return "操作成功";
}
网友评论