function drupal_cache_system_paths

drupal_cache_system_paths()

Cache system paths for a page.

Cache an array of the system paths available on each page. We assume that aliases will be needed for the majority of these paths during subsequent requests, and load them in a single query during drupal_lookup_path().

File

includes/path.inc, line 203
Functions to handle paths in Drupal, including path aliasing.

Code

function drupal_cache_system_paths() {
  // Check if the system paths for this page were loaded from cache in this
  // request to avoid writing to cache on every request.
  $cache = &drupal_static('drupal_lookup_path', array());
  if (empty($cache['system_paths']) && !empty($cache['map'])) {
    // Generate a cache ID (cid) specifically for this page.
    $cid = current_path();
    // The static $map array used by drupal_lookup_path() includes all
    // system paths for the page request.
    if ($paths = current($cache['map'])) {
      $data = array_keys($paths);
      $expire = REQUEST_TIME + (60 * 60 * 24);
      cache_set($cid, $data, 'cache_path', $expire);
    }
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/includes!path.inc/function/drupal_cache_system_paths/7.x