文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>独占的方式读写文件,经jmeter1000个线程并发访问测试没问题

独占的方式读写文件,经jmeter1000个线程并发访问测试没问题

时间:2008-01-11  来源:lib

独占的方式读写文件,经jmeter1000个线程并发访问测试没问题
?php
$filename = 't.txt';
print readToWrite($filename);
function readToWrite($filename){
    if($fp = @fopen($filename, 'r+b')) { // 打开文件流
        $content = 0;
        flock($fp, LOCK_EX); // 进行排它型锁定
        $content = file_get_contents($filename);
        $content = $content + 1;
        fwrite($fp, $content);
        flock($fp, LOCK_UN); // 释放锁定
        fclose($fp);
        return $content;
    } else {
        throw new Exception('发生问题了');
    }
}
?>


相关阅读 更多 +
排行榜 更多 +
方块枪战战场安卓版

方块枪战战场安卓版

飞行射击 下载
战斗火力射击安卓版

战斗火力射击安卓版

飞行射击 下载
空中防御战安卓版

空中防御战安卓版

飞行射击 下载