相同功能的Laravel / PHP变量以某种方式与会话相关联?

时间:2017-03-04 11:49:38

标签: php laravel laravel-5.2

这里发生了什么,我有laravel代码:

class HomeController extends Controller
{
    public function index()
    {
        $this->test();
    }

    public function index2()
    {
        $this->test();
    }

    private function test(){
        $milliseconds = round(microtime(true) * 1000);
        \DB::transaction(function (){
            $order = Order::find(1)->lockForUpdate()->first();
            $order->update(['session_id' => str_random(40)]);
            sleep(2);
        });
        $milliseconds2 = round(microtime(true) * 1000);
        echo 'milliseconds=' . ($milliseconds2 - $milliseconds) . ' ms';
    }
}

当我在浏览器结果中的两个选项卡中运行索引路径时:

first tab  : milliseconds=2068 ms
second tab : milliseconds=2065 ms

虽然一个请求大约需要2秒,但还需要4秒

当我在一个选项卡中运行索引路由时,第二个选项卡结果中的index2类似于:

first tab  : milliseconds=2082 ms
second tab : milliseconds=4117 ms

另外一个请求大约需要2秒,另外4秒。 这很奇怪,这里发生了什么?!??

0 个答案:

没有答案