enable APCu for caching with >= 32M and fix post_install to patch Ubuntu-16.04 /etc/php/7.0/cli/conf.d/20-apcu.ini

This commit is contained in:
Ralf Becker 2016-07-15 13:23:08 +02:00
parent 106a1b588f
commit 52d3aa70cd
2 changed files with 7 additions and 6 deletions

View File

@ -53,8 +53,9 @@ class Apcu extends Base implements Provider
/**
* Check if APC is available for caching user data
*
* Default shared memory size of 32M is just enough for the byte code cache,
* but not for caching user data, we only use APC by default if we have at least 64M.
* Default shared memory size of 32M, which is used only for user data in APCu.
* Unlike APC which shares the total memory with it's opcode cache 32M is ok
* for a small install.
*
* @return boolean true: apc available, false: not
*/
@ -75,8 +76,8 @@ class Apcu extends Base implements Provider
}
$size *= ini_get('apc.shm_segments');
// only cache in APC, if we have at least 64M available (default is 32M)
$available = $size >= 67108864;
// only cache in APCu, if we have at least 32M available (default is 32M)
$available = $size >= 33554432;
}
//error_log(__METHOD__."() size=$size returning ".array2string($available));
return $available;

View File

@ -724,7 +724,7 @@ function _ucr_secret($name)
*/
function check_fix_php_apc_ini()
{
if (extension_loaded('apc'))
if (extension_loaded('apc') || extension_loaded('apcu'))
{
$shm_size = ini_get('apc.shm_size');
$shm_segments = ini_get('apc.shm_segments');
@ -741,7 +741,7 @@ function check_fix_php_apc_ini()
phpinfo();
$phpinfo = ob_get_clean();
$matches = null;
if (preg_match('#(/[a-z0-5./-]+apcu?.ini)(,| |$)#mi', $phpinfo, $matches) &&
if (preg_match('#(/[a-z0-9./-]+apcu?.ini)(,| |$)#mi', $phpinfo, $matches) &&
file_exists($path = $matches[1]) && ($apc_ini = file_get_contents($path)))
{
$new_shm_size = 128 / $shm_segments;