hello

i've made some changes and though it would be nice to share ;)
the changes include:
- variable to turn on caching (false, no cache from cacherouter)
- detection of the module inc file (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,
    ),
  );
}

posting a similar version for authcache module

Comments

lpalgarvio’s picture

Issue tags: +settings.php

authcache suggestion here:
http://drupal.org/node/945656

tetramentis’s picture

May I also suggest adding this (commented on purpose) line to your simplified configuration:

// 'lock_dir' => getcwd() . '/sites/' . $_SERVER['SERVER_NAME'] . '/files/filecache',

This will complement my patch from #979462: using xcache: fopen() [function.fopen]: SAFE MODE Restriction in effect. The script whose uid is X is not allowed to access /tmp.

tetramentis’s picture

Status: Active » Needs review
lpalgarvio’s picture

updating to allow "default" domain

/**
* 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,
    ),
  );
}

it would be useful to share this code in the docs for new users that are installing the module, with an advert that they need to change $module_cacherouter_default to "TRUE" to enable "default" domain, and that they need to change $module_cacherouter_enabled to "TRUE" to enable it the module altogether.

// EDIT
changed default behavior to set as "default" domain
and also module path

geekgirlweb’s picture

Thanks for posting this, it was really helpful!

Krummrey’s picture

#4 works for me

lpalgarvio’s picture

Assigned: Unassigned » lpalgarvio
Status: Needs review » Reviewed & tested by the community

new version, with lots of changes.
placed file_exists in a IF iteration under the main IF iteration to reduce I/O when turned off.

for cache router (with support for bins):

/**
* Cache settings: Cache Router (cacherouter)
*
* Cache API for Anonymous users, running on file, db, apc, xcache or memcache engines.
*/
$module_cacherouter_enabled = FALSE; // change to TRUE to enable
$module_cacherouter_default = TRUE; // change to FALSE to specify subdomain
$module_cacherouter_inc = './sites/all/modules/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,
    ),
  );
 }
}

for auth cache (with support for cache router and memcache):

/**
 * 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) ) {
  if ( $module_cacherouter_enabled == TRUE ) {
    $conf['cache_inc_via_authcache'] = $module_authcache_inc;
  } elseif ( $module_memcache_enabled == TRUE ) {
    $conf['cache_inc'] = $module_authcache_inc;
  }
 }
}
lpalgarvio’s picture

Version: 6.x-1.x-dev » 6.x-1.0-rc1
Component: Documentation » Code

changed descriptions

lpalgarvio’s picture

changed descriptions

lpalgarvio’s picture

Title: suggestions for settings.php config snipet » suggestions for settings.php
Version: 6.x-1.0-rc1 » 6.x-1.0-rc2
Component: Code » Documentation
Category: task » feature
apaderno’s picture

Version: 6.x-1.0-rc2 » 6.x-1.x-dev
Issue summary: View changes
Status: Reviewed & tested by the community » Closed (outdated)

I am closing this issue, since it is for a Drupal version that now is not supported.
Please re-open it if the issue is also relevant for other project branches that require a supported Drupal version.