//存入队列 $redis = new Redis(); $redis->connect('127.0.0.1',6379); $good_number = 5000; for($i=0;$i<$good_number;$i++){ $redis->lPush('good_stock',1); } echo $redis->lLen('good_stock');
--------------------------------------------------------------------------------------------------------------------------------------
$i = 0; while (1){ $redis = new Redis(); $redis->connect('127.0.0.1',6379); //移除一个 $cont = $redis->lPop('good_stock'); if(!$cont){ echo $i.'秒杀失败';exit(); } $i++; }