伪代码:
<?php $watchKey = $redis->get("watchKey"); $total = 100; //数量 if($watchKey watch("watchKey"); $redis->multi(); //插入数据 $redis->hSet("watchList","user_id_".$user_id_, $data); $redis->set("watchKey",$watchKey++); $result = $redis->exec(); if($result){ echo "抢购成功!<br>"; if(function_exists("fastcgi_finish_request")){ fastcgi_finish_request(); processData($data); }else{ $watchList = $redis->hGetAll("watchList"); //Async Processing; } }else{ echo "手气不好"; die; } } ?>
以上就介绍了关于秒杀抢购中reids的使用,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。