diff --git a/README.txt b/README.txt index edfcb03..c4dbebd 100644 --- a/README.txt +++ b/README.txt @@ -12,11 +12,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. @@ -40,11 +40,9 @@ may be removed in future 6.x releases. Update $conf in settings.php to tell Drupal where the cache_inc file is: - $conf = array( - // The path to wherever memcache.inc is. The easiest is to simply point it - // to the copy in your module's directory. - 'cache_inc' => './sites/all/modules/memcache/memcache.inc', - ); + // The path to wherever memcache.inc is. The easiest is to simply point it + // to the copy in your module's directory. + $conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc'; ## SERVERS ## @@ -66,12 +64,16 @@ arrays to $conf; memcache_servers and memcache_bins. The arrays follow this pattern: 'memcache_servers' => array( - host1:port => cluster, - host2:port => cluster, + host1:port => cluster, + host2:port => cluster, hostN:port => cluster ) -'memcache_bins' => array(bin1 => cluster, bin2 => cluster, binN => cluster) +'memcache_bins' => array( + bin1 => cluster, + bin2 => cluster, + binN => cluster, +) The bin/cluster/server model can be described as follows: @@ -93,50 +95,51 @@ cache_page is mapped to the 'pages' cluster. Thus everything that gets cached, with the exception of the page cache (cache_page), will be put into 'default', or the 11211 instance. The page cache will be in 11212. -$conf = array( - ... - // Important to define a default cluster in both the servers - // and in the bins. This links them together. - 'memcache_servers' => array('10.0.0.1:11211' => 'default', - '10.0.0.1:11212' => 'pages'), - 'memcache_bins' => array('cache' => 'default', - 'cache_page' => 'pages'), -); + // Important to define a default cluster in both the servers + // and in the bins. This links them together. + $conf['memcache_servers'] = array( + '10.0.0.1:11211' => 'default', + '10.0.0.1:11212' => 'pages', + ); + $conf['memcache_bins'] = array( + 'cache' => 'default', + 'cache_page' => 'pages', + ); Here is an example configuration that has two clusters, 'default' and 'cluster2'. Five memcached instances are divided up between the two clusters. 'cache_filter' and 'cache_menu' bins go to 'cluster2'. All other bins go to 'default'. -$conf = array( - 'cache_inc' => './sites/all/modules/memcache/memcache.inc', - 'memcache_servers' => array('10.0.0.1:11211' => 'default', - '10.0.0.1:11212' => 'default', - '123.45.67.890:11211' => 'default', - '123.45.67.891:11211' => 'cluster2', - '123.45.67.892:11211' => 'cluster2'), - - 'memcache_bins' => array('cache' => 'default', - 'cache_filter' => 'cluster2', - 'cache_menu' => 'cluster2'), -); + $conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc'; + $conf['memcache_servers'] = array( + '10.0.0.1:11211' => 'default', + '10.0.0.1:11212' => 'default', + '123.45.67.890:11211' => 'default', + '123.45.67.891:11211' => 'cluster2', + '123.45.67.892:11211' => 'cluster2', + ); + $conf['memcache_bins'] = array( + 'cache' => 'default', + 'cache_filter' => 'cluster2', + 'cache_menu' => 'cluster2', + ); Here is an example configuration where the 'cache_form' bin is set to bypass memcache and use the standard table-based Drupal cache by assigning it to a cluster called 'database'. -$conf = array( - ... - 'memcache_servers' => array('10.0.0.1:11211' => 'default'), - 'memcache_bins' => array('cache' => 'default', - 'cache_form' => 'database'), -); + $conf['memcache_servers'] = array('10.0.0.1:11211' => 'default'); + $conf['memcache_bins'] = array( + 'cache' => 'default', + 'cache_form' => 'database', + ); ## memcache_extra_include and database.inc ## In the above example, mapping a bin to 'database' makes a cache be stored in the database instead of memcache. This is actually done by the file -database.inc, which is copy and pasted from DRUPAL/includes/cache.inc. +database.inc, which is copy and pasted from DRUPAL/includes/cache.inc. If you want to provide an alternate file instead of database.inc to handle the cache calls to 'database', override the variable memcache_extra_include in settings.php to provide the location of the file to include. This only @@ -149,36 +152,36 @@ 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', -); + $conf['memcache_key_prefix'] = 'something_unique'; + +You can set the prefix to be the path to your sites configuration +(location of settings.php) like so: + + $conf['memcache_key_prefix'] = basename(realpath(conf_path())); ## SESSIONS ## Here is a sample config that uses memcache for sessions. Note you MUST have a session and a users server set up for memcached sessions to work. -$conf = array( - 'cache_inc' => './sites/all/modules/memcache/memcache.inc', - 'session_inc' => './sites/all/modules/memcache/memcache-session.inc', - 'memcache_servers' => array( - 'localhost:11211' => 'default', - 'localhost:11212' => 'filter', - 'localhost:11213' => 'menu', - 'localhost:11214' => 'page', - 'localhost:11215' => 'session', - 'localhost:11216' => 'users', - ), - 'memcache_bins' => array( - 'cache' => 'default', - 'cache_filter' => 'filter', - 'cache_menu' => 'menu', - 'cache_page' => 'page', - 'session' => 'session', - 'users' => 'users', - ), -); + $conf['cache_inc'] = './sites/all/modules/memcache/memcache.inc'; + $conf['session_inc'] => './sites/all/modules/memcache/memcache-session.inc', + $conf['memcache_servers'] => array( + 'localhost:11211' => 'default', + 'localhost:11212' => 'filter', + 'localhost:11213' => 'menu', + 'localhost:11214' => 'page', + 'localhost:11215' => 'session', + 'localhost:11216' => 'users', + ); + $conf['memcache_bins'] => array( + 'cache' => 'default', + 'cache_filter' => 'filter', + 'cache_menu' => 'menu', + 'cache_page' => 'page', + 'session' => 'session', + 'users' => 'users', + ); ## TROUBLESHOOTING ## @@ -190,8 +193,8 @@ Failed to set key: Failed to set key: cache_page-...... 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 ##