【问题标题】:Does PHP OPcache also cache the file load from file_get_contents()?PHP OPcache 是否也缓存来自 file_get_contents() 的文件加载?
【发布时间】:2021-10-29 02:00:48
【问题描述】:

我无法在文档中或通过几个小时的谷歌搜索找到我的问题的答案。

本质上,这一切都归结为这段代码是否可以被 OPcache 缓存,包括 json 文件本身:

<?php
$array = json_decode(file_get_contents('./test.json'), true);

【问题讨论】:

  • 为什么不试试看会发生什么?另外,是什么让你认为 OPcache 缓存了函数返回的任何数据?

标签: php opcache


【解决方案1】:

不,OPcache 只是将您预编译的脚本缓存在内存中,因此 PHP 不需要在每个页面请求时读取和解析它。

OPcache 不会缓存您的代码结果,例如您的 file_get_contents() 调用的响应。

【讨论】:

    猜你喜欢
    • 2019-09-09
    • 2019-09-24
    • 2014-06-29
    • 2011-07-28
    • 2017-10-01
    • 2016-10-19
    • 2015-08-03
    • 2015-03-21
    • 2013-08-08
    相关资源
    最近更新 更多