drupal_render_cid_parts

Versions
7
drupal_render_cid_parts($granularity = NULL)

Helper function for building cache ids.

Parameters

$granularity One or more cache granularity constants, e.g. DRUPAL_CACHE_PER_USER to cache for each user seperately or DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE to cache seperately for each page and role.

Return value

An array of cache ID parts, always containing the active theme. If the locale module is enabled it also contains the active language. If $granularity was passed in, more parts are added.

▾ 3 functions call drupal_render_cid_parts()

drupal_render_cid_create in includes/common.inc
Create the cache ID for a renderable element.
forum_block_view in modules/forum/forum.module
Implement hook_block_view().
_block_get_cache_id in modules/block/block.module
Assemble the cache_id to use for a given block.

Code

includes/common.inc, line 5228

<?php
function drupal_render_cid_parts($granularity = NULL) {
  global $theme, $base_root, $user;

  $cid_parts[] = $theme;
  if (module_exists('locale')) {
    global $language;
    $cid_parts[] = $language->language;
  }

  if (!empty($granularity)) {
    // 'PER_ROLE' and 'PER_USER' are mutually exclusive. 'PER_USER' can be a
    // resource drag for sites with many users, so when a module is being
    // equivocal, we favor the less expensive 'PER_ROLE' pattern.
    if ($granularity & DRUPAL_CACHE_PER_ROLE) {
      $cid_parts[] = 'r.' . implode(',', array_keys($user->roles));
    }
    elseif ($granularity & DRUPAL_CACHE_PER_USER) {
      $cid_parts[] = "u.$user->uid";
    }

    if ($granularity & DRUPAL_CACHE_PER_PAGE) {
      $cid_parts[] = $base_root . request_uri();
    }
  }

  return $cid_parts;
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.