$redis = new \Redis(); $redis->connect('127.0.0.1',6379); $password = '123456'; $redis->auth($password); $mobile='1500000000'.rand(0,9); $number=10; //瓶颈 $length=$redis->lLen("mobile"); if($length<=$number){ $list_phone=$redis->lgetrange("mobile",0,-1); if(!in_array($mobile,$list_phone)){ $redis->rpush("mobile",$mobile); //存数据库 $count= Db::name('user')->where('tel',$mobile)->count(); if(!$count){ Db::name('user')->insert(['tel'=>$mobile]); } } }else{ $redis->lpop('mobile'); }
redis 简易并发处理
最新推荐文章于 2021-12-18 17:13:33 发布