hello

i've made some changes and though it would be nice to share ;)
the changes include:
- variables to turn on caching (false, no cache from cacherouter and/or authcache)
- detection of the module inc files (false, no crash)
- automatic path for domain (so the code will less likely need changes when adding to a new site. also good for multi-site environments built with symlinks)

/**
* Cache Router
*
* Cache API for Anonymous users, running on file, db, apc, xcache or memcache engines.
*/
$module_cacherouter_enabled = FALSE;
$module_cacherouter_inc = './sites/all/modules/performance/cacherouter/cacherouter.inc';
if ( file_exists($module_cacherouter_inc) && $module_cacherouter_enabled == TRUE ) {
  $conf['cache_inc'] = $module_cacherouter_inc;
  $conf['cacherouter'] = array(
    'default' => array(
      'engine' => 'file',
      'servers' => array(),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $_SERVER['SERVER_NAME'] . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => FALSE,
    ),
  );
}

/**
* Auth Cache
*
* Logged-in user backend for Cache Router.
*/
$module_authcache_enabled = FALSE;
$module_authcache_inc = './sites/all/modules/performance/authcache/authcache.inc';
if ( file_exists($module_authcache_inc) && $module_authcache_enabled == TRUE ) {
  $conf['cache_inc'] = $module_authcache_inc;
  $conf['cache_inc_via_authcache'] = $module_cacherouter_inc;
}

posted a similar version for cache router module here:
http://drupal.org/node/945650

Comments

Status:Active» Closed (won't fix)

Thanks for sharing, though it is kind of bulky and having a white screen of death is rather useful when people add the incorrect path.

WSoD is anything but useful.
i'd wish PHP team would change it to a more proper debug screen (when enabled in the php.ini).

the code is bulky, but so is settings.php, and there's not much we can do about it, except, try to improve it in little small ways, like this one.
not sure you missed the point, but the code is meant to allow an easy and fast way to disable and enable the modules and change paths; it autodetect domain paths (except in the case of "default" domain, to which a new variable and an if could easily be set), and also, selects the file cache method, which works out-of-the-box in any setup, and the recommended options for the rest.

i think it would be useful to share this code in the docs for new users that are installing the module, with an advert that it won't work for "default" domain, to which case they need to change $module_cacherouter_default to "TRUE", and that they need to change $module_cacherouter_enabled to "TRUE" to enable it.

i do know that i miss the point about won't fix.

small update:

/**
* Cache Router
*
* Cache API for Anonymous users, running on file, db, apc, xcache or memcache engines.
*/
$module_cacherouter_enabled = FALSE;
$module_cacherouter_default = TRUE;
$module_cacherouter_inc = './sites/all/modules/cacherouter/cacherouter.inc';
if ( file_exists($module_cacherouter_inc) && $module_cacherouter_enabled == TRUE ) {
  if ( $module_cacherouter_default == TRUE) {
      $module_cacherouter_domain = 'default';
  } else {
      $module_cacherouter_domain = $_SERVER['SERVER_NAME'];
  }
  $conf['cache_inc'] = $module_cacherouter_inc;
  $conf['cacherouter'] = array(
    'default' => array(
      'engine' => 'file',
      'servers' => array(),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => FALSE,
    ),
  );
}

/**
* Auth Cache
*
* Logged-in user backend for Cache Router.
*/
$module_authcache_enabled = FALSE;
$module_authcache_inc = './sites/all/modules/authcache/authcache.inc';
if ( file_exists($module_authcache_inc) && $module_authcache_enabled == TRUE ) {
  $conf['cache_inc'] = $module_authcache_inc;
  $conf['cache_inc_via_authcache'] = $module_cacherouter_inc;
}

Status:Closed (won't fix)» Active

new versions.

Auth Cache settings:

/**
* Cache settings: Auth Cache (authcache)
*
* Logged-in user backend for Cache Router and Memcache API.
*/
$module_authcache_enabled = TRUE; // change to TRUE to enable
$module_authcache_inc = './sites/all/modules/performance/authcache/authcache.inc';
if ( $module_authcache_enabled == TRUE ) {
if ( file_exists($module_authcache_inc) ) {
  if ( $module_cacherouter_enabled == TRUE ) {
    $conf['cache_inc_via_authcache'] = $module_authcache_inc;
  } elseif ( $module_memcache_enabled == TRUE ) {
    $conf['cache_inc'] = $module_authcache_inc;
  }
}
}

the support for memcache and cache router modules.

Memcache settings:

/**
* Cache settings: Memcache API (memcache)
*
* Cache API, running with memcache engine.
*/
$module_memcache_enabled = FALSE; // change to TRUE to enable
$module_memcache_inc = './sites/all/modules/performance/memcache/memcache.inc';
$module_memcache_session_inc = './sites/all/modules/performance/memcache/memcache-session.inc';
if ( $module_memcache_enabled == TRUE ) {
if ( file_exists($module_memcache_inc) ) {
  $conf['cache_inc'] = $module_memcache_inc;
  $conf['session_inc'] = $module_memcache_session_inc;
  $conf['memcache_servers'] = array(
    '127.0.0.1:11211' => 'default',
  );
  $conf['memcache_bins'] = array(
    'cache' => 'default',
    'cache_block' => 'default',
    'cache_bootstrap' => 'default',
    'cache_content' => 'default',
    'cache_filter' => 'default',
    'cache_form' => 'default',
    'cache_menu' => 'default',
    'cache_page' => 'default',
    'cache_pathdst' => 'default',
    'cache_pathsrc' => 'default',
    'cache_uc_price' => 'default',
    'cache_update' => 'default',
    'cache_views' => 'default',
    'cache_views_data' => 'default',
    'session' => 'default',
    'users' => 'default',
  );
}
}

Cache Router settings:

/**
* Cache settings: Cache Router (cacherouter)
*
* Cache API for Anonymous users, running on file, db, apc, xcache or memcache engines.
*/
$module_cacherouter_enabled = TRUE; // change to TRUE to enable
$module_cacherouter_default = FALSE; // change to FALSE to specify subdomain
$module_cacherouter_inc = './sites/all/modules/performance/cacherouter/cacherouter.inc';
if ( $module_cacherouter_enabled == TRUE ) {
if ( file_exists($module_cacherouter_inc) ) {
  if ( $module_cacherouter_default == TRUE ) {
      $module_cacherouter_domain = 'default';
  } else {
      $module_cacherouter_domain = $_SERVER['SERVER_NAME'];
  }
  $conf['cache_inc'] = $module_cacherouter_inc;
  $conf['cacherouter'] = array(
    'default' => array( // default bin, select default engine (memcache, apc, xcache, file or db)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache' => array( // general bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_block' => array( // block bin, select small storage engine (apc or db)
      'engine' => 'apc',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_bootstrap' => array( // bootstrap bin, select small storage engine (apc or db)
      'engine' => 'apc',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_content' => array( // field bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_filter' => array( // block bin, select small storage engine (apc or db)
      'engine' => 'apc',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_form' => array( // block bin, select small storage engine (apc or db)
      'engine' => 'apc',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_menu' => array( // menu bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_page' => array( // node bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_pathdst' => array( // path cache bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_pathsrc' => array( // path cache bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_uc_price' => array( // ubercart multiprice bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_update' => array( // module and theme bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_views' => array( // views bin, select large storage engine (memcache or file)
      'engine' => 'file',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
    'cache_views_data' => array( // views data bin, select small storage engine (apc or db)
      'engine' => 'apc',
      'servers' => array('127.0.0.1:11211'),
      'shared' => TRUE,
      'prefix' => '',
      'path' => 'sites/' . $module_cacherouter_domain . '/files/filecache',
      'static' => FALSE,
      'fast_cache' => TRUE,
    ),
  );
}
}

Version:6.x-6.x-dev» 6.x-1.0-rc2
Component:Documentation» Code
Issue tags:-default.settings.php+settings.php

changed descriptions

Title:suggestions for settings.php config snipetsuggestions for settings.php
Component:Code» Documentation
Category:task» feature
Status:Active» Reviewed & tested by the community

Status:Reviewed & tested by the community» Needs work
Issue tags:-settings.php

Is there a patch?

no need for a patch. this can be copy-pasted to the README file and to the documentation page.
http://drupal.org/node/996418

as in, "Example code provided to use in settings.php"

/**
* Cache settings: Auth Cache (authcache)
*
* Logged-in user backend for Cache Router and Memcache API.
*/
$module_authcache_enabled = TRUE; // change to TRUE to enable
$module_authcache_inc = './sites/all/modules/authcache/authcache.inc';
if ( $module_authcache_enabled == TRUE ) {
if ( file_exists($module_authcache_inc) ) {
  $conf['cache_inc'] = $module_authcache_inc;
  if ( $module_cacherouter_enabled == TRUE ) {
    $conf['cache_inc_via_authcache'] = $module_cacherouter_inc;
  } elseif ( $module_memcache_enabled == TRUE ) {
    $conf['cache_inc_via_authcache'] = $module_memcache_inc;
  }
}
}

i've asked for similar approach in cacherouter and memcache issue queue, so they add these vars:

$module_cacherouter_inc = './sites/all/modules/cacherouter/cacherouter.inc';
$module_memcache_inc = './sites/all/modules/memcache/memcache.inc';

Status:Needs work» Closed (fixed)