Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
Jonah Ellison CreditAttribution: Jonah Ellison commentedThanks for sharing, though it is kind of bulky and having a white screen of death is rather useful when people add the incorrect path.
Comment #2
lpalgarvio CreditAttribution: lpalgarvio commentedWSoD 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:
Comment #3
lpalgarvio CreditAttribution: lpalgarvio commentednew versions.
Auth Cache settings:
the support for memcache and cache router modules.
Memcache settings:
Cache Router settings:
Comment #4
lpalgarvio CreditAttribution: lpalgarvio commentedchanged descriptions
Comment #5
lpalgarvio CreditAttribution: lpalgarvio commentedComment #6
andypostIs there a patch?
Comment #7
lpalgarvio CreditAttribution: lpalgarvio commentedno 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"
i've asked for similar approach in cacherouter and memcache issue queue, so they add these vars:
Comment #8
simg CreditAttribution: simg commented