Is the new APCu APC User Cache shared between proc

2019-03-02 02:47发布

问题:

I am planning to use the php5-apcu ubuntu package.

Is the data shared between processes? In other words, if I set a cache entry in one website load, will another website load have the cache entry available, even if it is served with another process?

How does this work for:

  • the apache2 php prefork module
  • php5 fpm with multiple workers
  • php-cli

回答1:

https://github.com/krakjoe/apcu/issues/121

The rule is that only child processes can access what their parent created; In FCGI spawned processes are not necessarily a child of their parent, they may not be actual forks. If your process manager works like conventional FCGI/CGI then you will not be able to share, if it works like FPM, and initializes PHP in a parent and forks child interpreters then you will have no problem.

Apache's prefork and PHP's FPM will share between worker processes (via the parent's memory space).

The CLI will not, as each CLI invocation is a separate process.

You might consider something like memcached or redis as an alternative.