mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
* API: only cache in APC by default, if it has at least 64M of shared memory, otherwise use filesystem
This commit is contained in:
parent
6dbc821ec6
commit
a6190a6933
@ -527,13 +527,6 @@ class egw_cache
|
||||
}
|
||||
}
|
||||
|
||||
// setting apc as default provide, if apc_fetch function exists AND not cli or apc enabled for cli
|
||||
if (is_null(egw_cache::$default_provider))
|
||||
{
|
||||
egw_cache::$default_provider = function_exists('apc_fetch') && (PHP_SAPI != 'cli' || ini_get('apc.enable_cli')) ?
|
||||
'egw_cache_apc' : 'egw_cache_files';
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for a caching provider for tree and instance level
|
||||
*
|
||||
@ -632,6 +625,12 @@ abstract class egw_cache_provider_check implements egw_cache_provider
|
||||
}
|
||||
}
|
||||
|
||||
// setting apc as default provider, if apc_fetch function exists AND further checks in egw_cache_apc recommed it
|
||||
if (is_null(egw_cache::$default_provider))
|
||||
{
|
||||
egw_cache::$default_provider = function_exists('apc_fetch') && egw_cache_apc::available() ? 'egw_cache_apc' : 'egw_cache_files';
|
||||
}
|
||||
|
||||
// some testcode, if this file is called via it's URL
|
||||
// can be run on command-line: sudo php -d apc.enable_cli=1 -f phpgwapi/inc/class.egw_cache.inc.php
|
||||
/*if (isset($_SERVER['SCRIPT_FILENAME']) && realpath($_SERVER['SCRIPT_FILENAME']) == __FILE__)
|
||||
|
@ -40,6 +40,39 @@ class egw_cache_apc extends egw_cache_provider_check implements egw_cache_provid
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @return boolean true: apc available, false: not
|
||||
*/
|
||||
public static function available()
|
||||
{
|
||||
$available = false;
|
||||
if (function_exists('apc_fetch') && (PHP_SAPI != 'cli' || ini_get('apc.enable_cli')))
|
||||
{
|
||||
$size = ini_get('apc.shm_size');
|
||||
|
||||
switch(strtoupper(substr($size, -1)))
|
||||
{
|
||||
case 'G':
|
||||
$size *= 1024;
|
||||
case 'M':
|
||||
$size *= 1024;
|
||||
case 'K':
|
||||
$size *= 1024;
|
||||
}
|
||||
$size *= ini_get('apc.shm_segments');
|
||||
|
||||
// only cache in APC, if we have at least 64M available (default is 32M)
|
||||
$available = $size >= 64*1024*1024;
|
||||
}
|
||||
//error_log(__METHOD__."() size=$size returning ".array2string($available));
|
||||
return $available;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores some data in the cache
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user