zendtech / ZendOptimizerPlus

Other
914 stars 142 forks source link

files are not stored on cache #138

Closed 2ndkauboy closed 10 years ago

2ndkauboy commented 10 years ago

We've setup opcache and it is running. When I call opcache_get_status() within a script, I can see all included files in the "script" array of the output. When I run another script, I don't see the files from the first script. Running php -r "print_r(opcache_get_status());" in the shell shows me not a single file.

Here is our environment, if that might help:

PHP Version 5.3.3-7+squeeze17
Server API  CGI/FastCGI
Suhosin Extension 0.9.32.1

From the phpinfo():

Zend OPcache

Opcode Caching  Up and Running
Optimization    Enabled
Startup OK
Shared memory model mmap
Cache hits  0
Cache misses    1
Used memory 914128
Free memory 133303600
Wasted memory   0
Cached scripts  1
Cached keys 1
Max keys    16229
OOM restarts    0
Hash keys restarts  0
Manual restarts 0
Majkl578 commented 10 years ago

a) OPcache is disabled by default in CLI mode. b) CLI wouldn't be using same caching block as your webserver. Also, don't you run PHP in CGI mode, in which php binary is executed at its own each request? It would kill caching imho.

2ndkauboy commented 10 years ago

@Majkl578 We are running the server with FastCGI (not CGI) which is the prefered method for many huge website. And we also enabled OPcache for cli. So that's not the issue.

dstogov commented 10 years ago

OPCache doesn't share its cache across different processes. So it's expected that CLI process doesn't see any files cached by FastCGI processes.

FastCGI processes share the cache only if they have the common parent. (e.g. if you start one php-cgi with PHP_FCGI_CHILDREN=N, then all N processes share the same cache, if you start N php-cgi processes with PHP_FCGI_CHILDREN=0, then each process has a separate cache).

2ndkauboy commented 10 years ago

It looks like it was an issue with suPHP on our server. As soon as we deactivated suPHP the cache was shared.