简体   繁体   English

如何在PHP中使用opcache_compile_file()?

[英]How to use opcache_compile_file() in PHP?

I understand how caching works and how it improves performance. 我理解缓存是如何工作的以及它如何提高性能。 I couldn't find anywhere on the web that showed examples of this. 我无法在网上找到显示此示例的任何地方。 What are the best practices? 什么是最佳做法?

Internally, if the opcache_compile_file() function is executed I'm assuming that it checks to see if the file is already cached, and if so then quickly continue to the next statement (or the performance gain would be lost) this is a bit of a rhetorical question. 在内部,如果执行opcache_compile_file()函数,我假设它检查文件是否已经被缓存,如果是,那么快速继续下一个语句(或者性能增益会丢失)这是一点点一个修辞问题。

Finally, I'm using dependency injection and PHP seems to already do a good job of caching functions and classes even when using DI and instantiating on the fly. 最后,我正在使用依赖注入,PHP似乎已经很好地缓存了函数和类,即使在使用DI和动态实例化时也是如此。

Is the opcache_compile_file() function even needed? 是否需要opcache_compile_file()函数?

Is the opcache_compile_file() function even needed? 是否需要opcache_compile_file()函数?

No, you don't need to care about that. 不,你不需要关心那个。 The opcache works automatically, you have nothing to do. opcache自动运行,你无事可做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM