redis常用验证是否重试提交获取手机验证码

use Illuminate\Support\Facades\Redis;


try{
$is_exists = Redis::set($this->key,1,"EX",60,"NX");
if ($is_exists != null || Redis::incr($this->key)<=5){
$restul = [
"result" => true
];
return $restul;
}else{
$restul = [
'result' => false,
'message' => "请在1分钟后再进行尝试"
];
return $restul;
}
}catch (\Exception $exception){
$restul = [
'result' => false,
'message' => "系统异常,请稍后在尝试"
];
return $restul;
}
posted @ 2024-07-17 16:29  郑筱筱  阅读(8)  评论(0编辑  收藏  举报