Commit 7e9bc9e2 authored by Jeremy's avatar Jeremy

Issue #467226 by litwol, markpavlitski, bmhaskar, thedavidmeister, fago,...

Issue #467226 by litwol, markpavlitski, bmhaskar, thedavidmeister, fago, CurtisTAG, catch, Jeremy: Support for per-bin key prefix
parent e39d9d8b
......@@ -281,9 +281,22 @@ go to 'cluster2'. All other bins go to 'default'.
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:
array of settings.php. This can be a single string prefix, or a keyed array of
bin => prefix pairs:
$conf['memcache_key_prefix'] = 'something_unique';
$conf['memcache_key_prefix'] = 'something_unique';
Using a per-bin prefix:
$conf['memcache_key_prefix'] = array(
'default' => 'something_unique',
'cache_page' => 'something_else_unique'
);
In the above example, the 'something_unique' prefix will be used for all bins
except for the 'cache_page' bin which will use the 'something_else_unique'
prefix. Not that if using a keyed array for specifying prefix, you must specify
the 'default' prefix.
## MAXIMUM LENGTHS ##
......
......@@ -854,8 +854,18 @@ function dmemcache_object($bin = NULL, $flush = FALSE) {
*/
function dmemcache_key($key, $bin = 'cache') {
$prefix = '';
if ($prefix = variable_get('memcache_key_prefix', '')) {
$prefix .= '-';
if ($prefixes = variable_get('memcache_key_prefix', '')) {
if (is_array($prefixes)) {
if (!empty($prefixes[$bin])) {
$prefix = $prefixes[$bin] . '-';
} // Support default prefix for site
elseif (!empty($prefixes['default'])) {
$prefix = $prefixes['default'] . '-';
}
}
else {
$prefix = $prefixes . '-';
}
}
// When simpletest is running, emulate the simpletest database prefix here
// to avoid the child site setting cache entries in the parent site.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment