时间:2021-07-01 10:21:17 帮助过:2人阅读
坐等斑竹评论
坐等楼主给分
请lz支援资源分
你们自己评价一下,值不值得化 5 分
filename; } /** * 设置并发访问人数 * @param number $count */ public function setCount($count) { $this->count = $count; } function __construct(){ $dir="./_runlist"; $this->filename=$dir."/~Supervene"; if(!is_dir($dir)){ mkdir($dir); } } /** * 缓存队列 */ private function saveCache($value){ $cache=self::read(); $time = date("YmdHis",time()); $wcache=""; if(!$cache){ $warr[$value]=$time; $wcache = serialize($warr); }else{ $warr=unserialize($cache); $warr_rs=array_keys($warr,$time); if(empty($warr_rs)){ unset($warr); $warr[$value]=$time; $wcache = serialize($warr); }else{ if(count($warr_rs)<$this->count){ $warr[$value]=$time; $wcache = serialize($warr); }else{ return false; } } } if($wcache!==""){ self::write($wcache); return true; }else{ return false; } } /** * 读取缓存 */ private function read(){ $fread = fopen(self::getFilename(), "r"); if($fread){ $contents = fread($fread, filesize (self::getFilename())); fclose($fread); return $contents; }else{ return false; } } /** * 写入缓存 */ private function write($value){ $fwrite = fopen(self::getFilename(), 'w+'); fwrite($fwrite, $value); fclose($fwrite); } /** * 主入口 * @param unknown_type $ip */ public function Supervene($ip){ if(!self::saveCache($ip)){ echo ""; exit; } }}?>
收藏,以后学学