/**
10 * Perform lock operation. What is the specific function of this function? Thanks
11 * @param [type] $lock_id
12 * @param integer $expire
13 */
14 public function Lock($lock_id,$expire=5){
15 $mkey = self::KEY_PREFIX.$lock_id;
16 for($i = 0; $i < 10; $i++){
17 $flag = false;
18 try{
19 $flag = $this->mc->add($mkey,'1',$expire);
20 }catch(Exception $e){
21 $flag = false;
22 //log
twenty three }
24 if($flag){
25 return true;
26 }else{
27 //wait for 0.3 seconds
28 usleep(300000);
29 }
30}
31 return false;
32}
習慣沉默2017-05-16 13:02:31
/q/10...
Here are the answers you want. The principles are almost the same