Php read and write variables [large concurrency]

[1] Today, I made an official account to reply to the keyword php of grabbing red packets. Use a redis variable to record the number of red packets sent. If it reaches 100, it will be snatched up. As a result, the redis variable no longer changes at 56, and the money in the account is emptied: ([2] find a variable reading and writing method that can adapt to high concurrency [3] my code is summarized as follows

    `
    $redis = new Redis();                   
    $redis->connect("127.0.0.1","8090");
    $num_s = $redis->get("num");
    $num = intval( $num_s );

    if(  $num<100 ){         
    $opid = strval( $msg->FromUserName );
    
    require(dirname(__FILE__) . "\redpack.php");  //
             
    if( "SENDNUM_LIMIT"===$result){
      $wechat->reply( "" );
    }elseif( $result===true ){
      $redis->set("num", strval(PP$num) );
      echo "";exit;
    } 
    else {            echo "";exit;        }
  } 
  else {
    $wechat->reply("");
  }        

`

Dec.06,2021

if you fail to send $num, you may also PP


you need to add one before sending red packets, so that even if you fail to send red packets, it does not affect the total amount. Reduce it by one after failure.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e675cc-45c2e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e675cc-45c2e.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?