I'm attempting to install the APC module on Drupal 7 in a multisite environment. To do the implementation, I've enabled the APC module and updated my settings.php file according to the documentation suggestions. Here's the code:
/**
* Add APC Caching.
/*
$conf['cache_backends'] = array('sites/all/modules/contrib/apc/drupal_apc_cache.inc');
$conf['cache_default_class'] = 'DrupalAPCCache';
//$conf['apc_show_debug'] = TRUE; // Remove the slashes to use debug mode.
After implementing both, the APC module appears to have installed correctly and I'm able to go to my Reports/Status and see that APC is running and caching x entries and using xkb.
The issue I'm having is that after installation, when I access node content from one site, it is apparently pulling content from one of the other sites in the multi-site configuration. As configured, each of my sites has its own database, but each of the databases is more or less storing identical content.
It appears to me that Site A, when displaying Node 1, is grabbing Node 1 content from Site B. I'm guessing this is an issue with Site A grabbing Node 1 from the APC cache and and not the database as I've doublechecked all of the database configuration information in the settings.php file to make sure it is correct. Likewise, when I remove the APC caching code from the settings.php file, the problem goes away.
Any ideas what is causing this or how I can troubleshoot this issue?
Comments
Key prefix
I'm not sure if the APC module supports key prefixes (I use memcache, which does), but that's probably what your problem is. Site1.org stores something with "key1" and then site2.org tries to use the same key, not knowing site1 has already claimed it. You need to add key prefixes per-site - "site1.org_key1", "site2.org_key1" - in order to give each site its own namespace.
Check out: http://drupal.org/node/1052788
Thanks for the reply.
I actually have this working correctly on another Drupal installation, so I'm not sure that's the case (but I certainly could be wrong). I'm in the process of migrating from a shared hosting platform to a cloud-based virtual private server. In my shared hosting environment I've set up the APC module following the same method I've employed for my cloud-based instance and didn't have any issues.
Could this be an Alternative PHP Cache or server configuration issue? That's the only thing that I think would really be different between the two environments.
You want to look into cache
You want to look into cache prefixing. I.e. two instances of Drupal are sharing the same cache. There's no way to distinguish keys from one site to another. Prefixing keys solves the issue, but it doesn't look like apc module supports this yet. Perhaps switch to memcached?
From http://drupal.org/project/memcache README.txt
PREFIXING
If you want to have multiple Drupal installations share memcached instances,
you need to include a unique prefix for each Drupal installation in the $conf
array of settings.php:
$conf = array(
...
'memcache_key_prefix' => 'something_unique',
);
Check this, it might be some
Check this, it might be of some help - http://groups.drupal.org/node/191998
Vaibhav Jain
cache_prefix
APC module supports
$conf['cache_prefix'](fixed issue 1052788)Awesome - didn't check the
Awesome - didn't check the module.
Thanks for the update ogi :)