dtoaillwk759656786 2018-01-09 12:50
浏览 134
已采纳

非常大的2.5mb php文件会opcache缓存吗?

I have a project in which I have a large array with locations having certain timezones.

I do not wish to use a database because that would mean too many database hits and writing Yet Another Caching Mechanism to prevent database hits.

So I made it into a php file with arrays. Currently it's 2.5mb on disc.
I could trim down the arrays to save on some info I don't need at this point in time but might in the future(geographic location, city names, altitude etc..)

Since I have opcache enabled, I am hoping that opcache will cache this very large file, saving the disc hits, keeping the data readily available.

can someone confirm opcache will also cache this large 2.5mb file? or give me a method to test/verify this file is cached?

  • 写回答

1条回答 默认 最新

  • dsq2015 2018-01-09 13:13
    关注

    Yes, opcache will cache it.

    By looking at the code from the tool commented by MarkBaker I was able to get this simple verify script out to see if the file is cached or not.

    Al you need is the absolute path to the file, and then you can easily check if it's cached or not.

    <pre><?php 
    $status = opcache_get_status();
    $scripts = $status['scripts'];
    $file = 'F:\cmslib-dev\include\lib\locations\Locations.php';
    
    if(array_key_exists($file, $scripts)) {
        var_dump($scripts[$file]);
    }
    else {
        echo "$file is not cached";
    }
    ?>
    </pre>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器