xCache will feel useless until you actually start to put some variables in cache. If you're showing the "Who is online" counter, that's one of the best item there is to implement xCache.<br/>
For example, you could implement it this way (in main/inc/banner.inc.php):<br/>
For example, you could implement it this way (in main/inc/lib/banner.lib.php):<br/>
<pre>
$xc = function_exists('xcache_isset');
$number = 0;
if ($xc && xcache_isset('campus_chamilo_org_whoisonline_count_simple')) {
if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) {
if ($xc && xcache_isset('campus_chamilo_org_whoisonline_count_simple')) {
Note that, as xCache is a shared caching system, it is very important to prefix your variables with a domain name or some kind of identifier, otherwise it would end up in disaster if you use a shared server for several portals.<br/>
<br/>
An optional additional caching mechanism you may use is the realpath_cache_size and realpath_cache_ttl php.ini parameters. See <ahref="http://php.net/manual/en/ini.core.php">the PHP documentation</a> for more details.
<br/>
<br/>
If you prefer using <ahref="http://php.net/manual/en/book.apc.php">APC</a>, you can use the same kind of trick as above, just changing the code a little:
<pre>
$xc = function_exists('apc_exists');
$number = 0;
if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) {
if ($xc) {
$apc = apc_cache_info(null,true);
$apc_end = $apc['start_time']+$apc['ttl'];
if (apc_exists('my_campus_whoisonline_count_simple') AND (time() < $apc_end) AND apc_fetch('my_campus_whoisonline_count_simple') > 0 ) {
if (apc_exists('my_campus_whoisonline_count_simple_'.$_course['id']) AND (time() < $apc_end) AND apc_fetch('my_campus_whoisonline_count_simple_'.$_course['id']) > 0) {