? .svn ? memcached.bin-key-prefix.patch ? memcache_admin/.svn Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/README.txt,v retrieving revision 1.4.2.10.2.5 diff -u -r1.4.2.10.2.5 README.txt --- README.txt 29 Jan 2009 18:01:47 -0000 1.4.2.10.2.5 +++ README.txt 19 May 2009 17:52:42 -0000 @@ -5,11 +5,11 @@ These are the broad steps you need to take in order to use this software. Order is important. -1. Install the memcached binaries on your server. See +1. Install the memcached binaries on your server. See http://www.lullabot.com/articles/how_install_memcache_debian_etch -2. Install the PECL memcache extension for PHP. This must be version 2.2.1 or +2. Install the PECL memcache extension for PHP. This must be version 2.2.1 or higher or you will experience errors. 3. Put your site into offline mode. 4. Download and install the memcache module. @@ -71,8 +71,8 @@ pattern: 'memcache_servers' => array( - host1:port => cluster, - host2:port => cluster, + host1:port => cluster, + host2:port => cluster, hostN:port => cluster ) @@ -131,9 +131,28 @@ you need to include a unique prefix for each Drupal installation in the $conf array of settings.php: +The following will use the same prefix for all bins $conf = array( ... - 'memcache_key_prefix' => 'something_unique', + 'default_key_prefix' => 'something_unique', +); + +More granular control over key prefixes per bin can be achieved using the following method +# site 1 +$conf = array( + ... + 'default_key_prefix' => array( + 'default_key_prefix' => 'something_unique_for_site1', //Will be used for all bins that do not override default prefix + 'cache_menu' => 'shared_bin_for_all_sites', //shared bin + ), +); +#site 2 +$conf = array( + ... + 'default_key_prefix' => array( + 'default_key_prefix' => 'something_unique_for_site2', //Will be used for all bins that do not override default prefix + 'cache_menu' => 'shared_bin_for_all_sites', //shared bin + ), ); ## SESSIONS ## @@ -172,8 +191,8 @@ SOLUTION: Upgrade your PECL library to PECL package (2.2.1) (or higher). -WARNING: -Zlib compression at the php.ini level and Memcache conflict. +WARNING: +Zlib compression at the php.ini level and Memcache conflict. See http://drupal.org/node/273824 ## MEMCACHE ADMIN ## Index: dmemcache.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/dmemcache.inc,v retrieving revision 1.1.2.7.2.4 diff -u -r1.1.2.7.2.4 dmemcache.inc --- dmemcache.inc 26 Jan 2009 21:12:04 -0000 1.1.2.7.2.4 +++ dmemcache.inc 19 May 2009 17:52:42 -0000 @@ -66,12 +66,12 @@ // try and grab a lock. If we get the lock, we return FALSE instead of // the cached object which should cause it to be rebuilt. If we do not // get the lock, we return the cached object. The goal here is to avoid - // cache stampedes. + // cache stampedes. // By default the cache stampede semaphore is held for 15 seconds. This // can be adjusted by setting the memcache_stampede_semaphore variable. // TODO: Can we log when a sempahore expires versus being intentionally // freed to track when this is happening? - if ($result->expire && $result->expire <= time() && $mc->add($full_key .'_semaphore', '', FALSE, variable_get('memcache_stampede_semaphore', 15))) { + if (isset($result->expire) && $result->expire && $result->expire <= time() && $mc->add($full_key .'_semaphore', '', FALSE, variable_get('memcache_stampede_semaphore', 15))) { $result = FALSE; } else { @@ -226,9 +226,8 @@ // memcache_key_prefix can be set in settings.php to support site namespaces // in a multisite environment. if (empty($prefix)) { - $prefix = variable_get('memcache_key_prefix', ''); + $prefix = variable_get('default_key_prefix', ''); } - $full_key = ($prefix ? $prefix. '-' : '') . $bin . '-' . $key; - + $full_key = (isset($prefix[$bin]) ? $prefix[$bin]. '-' : (isset($prefix['default_key_prefix']) ? $prefix['default_key_prefix'] : '') . '-') . $bin . '-' . $key; return urlencode($full_key); } Index: memcache-session.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/memcache-session.inc,v retrieving revision 1.1.2.2.2.8 diff -u -r1.1.2.2.2.8 memcache-session.inc --- memcache-session.inc 26 Jan 2009 15:11:08 -0000 1.1.2.2.2.8 +++ memcache-session.inc 19 May 2009 17:52:42 -0000 @@ -24,13 +24,13 @@ // So we are moving session closure before destructing objects. register_shutdown_function('session_write_close'); + // Handle the case of first time visitors and clients that don't store // cookies (eg. web crawlers). if (!isset($_COOKIE[session_name()])) { $user = drupal_anonymous_user(); return ''; } - // Otherwise, if the session is still active, we have a record of the // client's session in memcache. $session = dmemcache_get($key, 'session'); Index: memcache.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/memcache/memcache.inc,v retrieving revision 1.15.2.8.2.5 diff -u -r1.15.2.8.2.5 memcache.inc --- memcache.inc 29 Jan 2009 18:01:47 -0000 1.15.2.8.2.5 +++ memcache.inc 19 May 2009 17:52:42 -0000 @@ -7,7 +7,7 @@ /** * Return data from the persistent cache. - * + * * Data may be stored as either plain text or as serialized data. * cache_get() will automatically return unserialized objects and arrays. * @@ -23,7 +23,7 @@ // Retrieve the item from the cache. $cache = dmemcache_get($cid, $table); if (is_object($cache)) { - $cache_tables = $_SESSION['cache_flush']; + $cache_tables = isset($_SESSION['cache_flush']) ? $_SESSION['cache_flush'] : array(); // Items cached before the cache was last flushed are no longer valid. $cache_lifetime = variable_get('cache_lifetime', 0); if ($cache_lifetime && $cache->created && $cache_flush && @@ -46,7 +46,7 @@ * The cache ID of the data to store. * @param $data * The data to store in the cache. Complex data types will be automatically - * serialized before insertion. Strings will be stored as plain text and + * serialized before insertion. Strings will be stored as plain text and * not serialized. * @param $table * The table $table to store the data in. Valid core values are 'cache_filter', @@ -90,7 +90,7 @@ * entries will be cleared from the cache_page and cache_block tables. * * Memcache logic is simpler than the core cache because memcache doesn't have - * a minimum cache lifetime consideration (it handles it internally), and + * a minimum cache lifetime consideration (it handles it internally), and * doesn't support wildcards. Wildcard flushes result in the entire table * being flushed. *