简体   繁体   English

如何使用opcache_reset函数?

[英]How to use opcache_reset function?

I have some troubles using the opcache_reset function. 使用opcache_reset函数遇到一些麻烦。 I'm working on a Symfony 2 project. 我正在从事Symfony 2项目。 I have to use this function, so I created a route who applies this function then it redirect me to the homepage. 我必须使用此功能,因此我创建了一个路由,该路由应用了此功能,然后将我重定向到首页。

But my function want to call the opcache_reset function from my namespace, is there a way to tell that the opcache_reset function is "native" and call the right function? 但是我的函数想从我的命名空间中调用opcache_reset函数,是否有办法告诉opcache_reset函数是“ native”并调用正确的函数?

Here is my error : 这是我的错误:

 Attempted to call function "opcache_reset" from namespace "AppBundle\Controller".

And here is my function : 这是我的功能:

public function resetOpcacheAction(Request $request) {
    try{
        opcache_reset()

    } catch(\Exception $e){

    }
    return $this->redirect('homepage');
}

This function resets the entire opcode cache. 此功能重置整个操作码缓存。 After calling opcache_reset(), all scripts will be reloaded and reparsed the next time they are hit. 调用opcache_reset()之后,所有脚本将在下次命中时重新加载并重新分析。

What is opchache ? 什么是op子?

OpCache – which stores precompiled script bytecode in the memory. OpCache –将预编译的脚本字节码存储在内存中。 As each PHP script is being compiled at runtime, a part of the execution time gets used for transforming the human readable code into code that can be understood by the machine. 在运行时编译每个PHP脚本时,将执行时间的一部分用于将人类可读的代码转换为机器可以理解的代码。 A bytecode cache engine like OpCache, APC or Xcache does it only once – during the first execution of a specific PHP file. 字节码缓存引擎(如OpCache,APC或Xcache)仅在一次特定PHP文件执行期间执行一次。 Then the precompiled script is being stored in memory, which should lead to performance boosts in our PHP applications. 然后,将预编译的脚本存储在内存中,这将导致PHP应用程序的性能提高。

Use like this:- 像这样使用:

opcache_reset();

Reference link:- https://hotexamples.com/examples/-/-/opcache_reset/php-opcache_reset-function-examples.html 参考链接: -https : //hotexamples.com/examples/-/-/opcache_reset/php-opcache_reset-function-examples.html

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

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