| 1 |
// $Id$
|
| 2 |
|
| 3 |
The Path Cache module stores paths in a cache so that Drupal does not have
|
| 4 |
to look them up from the database.
|
| 5 |
|
| 6 |
If you want to use this module, use memcached or another memory-based caching
|
| 7 |
backend. It will still work if your caching backend is not memcached (Drupal's
|
| 8 |
default caching backend is MySQL) but it will actually make things slower.
|
| 9 |
|
| 10 |
STEP ONE: Make sure memcached (the Unix daemons) are working. See, for example:
|
| 11 |
|
| 12 |
http://www.lullabot.com/articles/how_install_memcache_debian_etch
|
| 13 |
http://www.lullabot.com/articles/setup-memcached-mamp-sandbox-environment
|
| 14 |
|
| 15 |
STEP TWO: Make sure the Memcache API and Integration stuff is set up. See
|
| 16 |
|
| 17 |
http://drupal.org/project/memcache
|
| 18 |
|
| 19 |
STEP THREE: Create two memcached bins named pathdst and pathsrc. A sample
|
| 20 |
configuration for settings.php is shown below. Note this configuration
|
| 21 |
contains some other bins too.
|
| 22 |
|
| 23 |
$conf = array(
|
| 24 |
// Enable memcache caching backend.
|
| 25 |
'cache_inc' => './sites/all/modules/memcache/memcache.inc',
|
| 26 |
// Enable memcached-based sessions.
|
| 27 |
'session_inc' => './sites/all/modules/memcache/memcache-session.inc',
|
| 28 |
'memcache_servers' => array(
|
| 29 |
'localhost:11211' => 'default',
|
| 30 |
'localhost:11212' => 'filter',
|
| 31 |
'localhost:11213' => 'menu',
|
| 32 |
'localhost:11214' => 'page',
|
| 33 |
'localhost:11215' => 'session',
|
| 34 |
'localhost:11216' => 'users',
|
| 35 |
'localhost:11217' => 'pathdst',
|
| 36 |
'localhost:11218' => 'pathsrc',
|
| 37 |
),
|
| 38 |
'memcache_bins' => array(
|
| 39 |
'cache' => 'default',
|
| 40 |
'cache_filter' => 'filter',
|
| 41 |
'cache_menu' => 'menu',
|
| 42 |
'cache_page' => 'page',
|
| 43 |
'session' => 'session',
|
| 44 |
'users' => 'users',
|
| 45 |
'cache_pathdst' => 'pathdst',
|
| 46 |
'cache_pathsrc' => 'pathsrc',
|
| 47 |
),
|
| 48 |
);
|
| 49 |
|
| 50 |
STEP FOUR: Make sure memcached daemons are actually running on the ports
|
| 51 |
you assigned. At the command line:
|
| 52 |
|
| 53 |
ps aux | grep memc
|
| 54 |
|
| 55 |
STEP FIVE: Apply the patch to includes/path.inc. At the command line:
|
| 56 |
|
| 57 |
cd /path/to/your/drupal/root
|
| 58 |
patch < sites/all/modules/pathcache/path.inc.patch
|
| 59 |
|
| 60 |
This adds caching to drupal_lookup_path() in path.inc.
|
| 61 |
|
| 62 |
The patch is against Drupal 6.
|
| 63 |
|
| 64 |
STEP SIX: Enable pathcache.module. All the module does is make sure that
|
| 65 |
the path caches get cleared when someone clicks the Clear cached data button
|
| 66 |
on the Administer -> Site configuration -> Performance page.
|
| 67 |
|
| 68 |
PERFORMANCE
|
| 69 |
|
| 70 |
The sites with the most to gain from path caching in memcache are sites that
|
| 71 |
have many path aliases, and a very busy database. Every cache hit in memcache
|
| 72 |
is one query that the database does not have to handle. Obviously every site
|
| 73 |
is different and you'll need to test to make sure that this module actually
|
| 74 |
improves things instead of making them worse.
|