php redis秒杀
function get(){
$random = rand(0,9);
if($random !== 0){
return $this->out("get fail");
}
$count = $this->redis->get("flag");
if($count < 100000){
$random = RandomKey::string(32);
if(empty($count)){
$count = 1;
$this->redis->set("flag", $count);
}
if($this->redis->zAdd("goods", $count, $random)){
$this->redis->incr("flag");
return $this->out("good luck");
}
}
else{
return $this->out("finish");
}
return $this->out("get fail");
}