Index: includes/path.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/path.inc,v retrieving revision 1.13 diff -u -r1.13 path.inc --- includes/path.inc 23 Dec 2006 22:04:52 -0000 1.13 +++ includes/path.inc 13 Jan 2007 21:58:16 -0000 @@ -52,14 +52,30 @@ if ($action == 'wipe') { $map = array(); $no_src = array(); + dmemcache_flush('alias'); + dmemcache_flush('src'); } elseif ($count > 0 && $path != '') { if ($action == 'alias') { + // static cache if (isset($map[$path])) { return $map[$path]; } + // memcache + if ($alias = dmemcache_get($path, 'alias')) { + $map[$path] = $alias['value']; + return $alias['value']; + } + // database $alias = db_result(db_query("SELECT dst FROM {url_alias} WHERE src = '%s'", $path)); $map[$path] = $alias; + if (!$alias) { + $mc_value = array('value' => $alias); + dmemcache_set($path, $mc_value, 300, 'alias'); + } + else { + dmemcache_set($path, array('value' => $alias), 300, 'alias'); + } return $alias; } // Check $no_src for this $path in case we've already determined that there @@ -67,9 +83,14 @@ elseif ($action == 'source' && !isset($no_src[$path])) { // Look for the value $path within the cached $map if (!$src = array_search($path, $map)) { - if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) { + if ($mc_src = dmemcache_get($path, 'src')) { + $src = $mc_src['value']; $map[$src] = $path; } + else if ($src = db_result(db_query("SELECT src FROM {url_alias} WHERE dst = '%s'", $path))) { + $map[$src] = $path; + dmemcache_set($path, array('value' => $src), 300, 'src'); + } else { // We can't record anything into $map because we do not have a valid // index and there is no need because we have not learned anything @@ -77,6 +98,7 @@ $no_src[$path] = TRUE; } } + return $src; } } Index: modules/path/path.module =================================================================== RCS file: /cvs/drupal/drupal/modules/path/path.module,v retrieving revision 1.105 diff -u -r1.105 path.module --- modules/path/path.module 9 Jan 2007 08:34:03 -0000 1.105 +++ modules/path/path.module 13 Jan 2007 21:58:16 -0000 @@ -118,6 +118,8 @@ * Post-confirmation; delete an URL alias. */ function path_admin_delete($pid = 0) { + dmemcache_flush('src'); + dmemcache_flush('alias'); db_query('DELETE FROM {url_alias} WHERE pid = %d', $pid); drupal_set_message(t('The alias has been deleted.')); } @@ -128,6 +130,9 @@ * Set an aliased path for a given Drupal path, preventing duplicates. */ function path_set_alias($path = NULL, $alias = NULL, $pid = NULL) { + dmemcache_flush('src'); + dmemcache_flush('alias'); + if ($path && !$alias) { db_query("DELETE FROM {url_alias} WHERE src = '%s'", $path); drupal_clear_path_cache();