1 path.inc backdrop_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 backdrop_lookup_path().

File

core/includes/path.inc, line 187
Functions to handle paths in Backdrop, including path aliasing.

Code

function backdrop_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 = &backdrop_static('backdrop_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 backdrop_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('path')->set($cid, $data, $expire);
    }
  }
}