zend_accelerator_module.c declares two API document calls: opcache_reset() and opcache_invalidate() , as well as two undocumented opcache_get_status() : opcache_get_status() and opcache_get_configuration() . What they do is pretty obvious from the source.
When opcache_reset() it will explicitly apply only to the OPcache cache, which is connected to the process that runs your PHP script. And yes, you can have many such caches in the system.
When you opcache.enable_cli=1 in a php-cli request , then OPcache issues a restart request for the cache that is connected to this process; Unfortunately, cli SAPI creates a private cache, so this is not very good.
The main thing to understand on * nix systems is that OPcache relies on some process manager, such as Apache or FPM, to run OPcache, forcing it with mmap() SMA, which contains the cache. Then, the process manager forks the child processes that serve the requests, and also accidentally inherits the mmapped area from the parent.
So, if you want to reset the OPcache cache connected to PHP-FPM, then you must execute this through a script running under the PHP-FPM service. This is just a 4-liner. If you want to do this from the command line, you can use the wget, curl or PHP CLI script, which uses the curl extension to trigger this FPM script.
But be sure to use some kind of strong authentication mechanism between them to prevent third-party developers from working.
If you want to understand a little more, I did this review: Zend Engine and operation code caching . If you have feedback or questions, comment here or raise a question on Github.
source share